WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Map API question to help fix old addon (https://www.wowinterface.com/forums/showthread.php?t=56513)

Machinelf 08-08-18 03:21 PM

Map API question to help fix old addon
 
Trying to get an old addon (Equipped Forager) that worked only in Pandaria after the Map API changes in BFA. The offending line of code is

if GetCurrentMapContinent() == 6 then

"6" corresponded to Pandaria. AFAIK the new ID is "862," but GetCurrentMapContinent is no more.
The new APi seems to be still in development, and I could spend a few trying to plug things in and out, but /dumping all the new Gets returns nil in game so I am asking here first before i dive further in.
Does anyone have simple replacement for the line above? I have tried to look through other addons on Curse to see how others may have done this to no avail.
The addon works fine if I comment out the line above, and the "end." But it absolutely has to be manually disabled when not in Pandaria. Which is a PITA.

Edit: found it
local map = C_Map.GetMapInfo(C_Map.GetBestMapForUnit("player"))
local parent = C_Map.GetMapInfo(map.parentMapID)
if parent.name == "Pandaria" then

Xrystal 08-08-18 05:47 PM

To get the current mapID relevant to the player then use the following:

C_Map.GetBestMapForUnit('player')

This will return a mapID which is used for all the map related functions in 8.0

Using the built in /api search tool in game you can view information using slash commands and clicking of links in the chatframe.

EG. /api system list will list all apis with clickable names

Amongst them will be MapUI which is what you need

This will result in an auto '/api mapui list' result in the chat window showing functions, variables and events relating to the map systen. That and some trial and error to see what you need to do to get the info you need at the right time will be all you need to do.

Fizzlemizz 08-08-18 05:58 PM

As posted in that other forum.
To walk up the maps from where you are to the continent you're on:
Lua Code:
  1. local thisMapType = 0
  2. local mapID = C_Map.GetBestMapForUnit("player")
  3. while thisMapType ~= 2 do
  4.     local mapDetails = C_Map.GetMapInfo(mapID)
  5.     local thisMapID = mapDetails.MapID
  6.     local thisMapName = mapDetails.name
  7.     thisMapType = mapDetails.mapType
  8.     local thisMapParent = mapDetails.parentMapID
  9.     mapID = thisMapParent
  10.     print(type(thisMapType), thisMapType, thisMapName)
  11. end
mapTypes
Code:

0 = "Cosmic"
1 = "World"
2 = "Continent"
3 = "Zone"
4 = "Dungeon"
5 = "Micro"
6 = "Orphan"


Machinelf 08-08-18 10:51 PM

It's kinda funny it takes 3 non-intuitive lines of code to do what used to be 1 line of intuitive code :D
Although someone on MMOC helped me find the solution, along the way I found the APIInterface addon on curse helpful in fleshing this out


All times are GMT -6. The time now is 08:39 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI