Thread Tools Display Modes
08-08-18, 03:21 PM   #1
Machinelf
A Murloc Raider
Join Date: Oct 2011
Posts: 4
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

Last edited by Machinelf : 08-08-18 at 05:55 PM.
  Reply With Quote
08-08-18, 05:47 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
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.
__________________
  Reply With Quote
08-08-18, 05:58 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
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"
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-08-18, 10:51 PM   #4
Machinelf
A Murloc Raider
Join Date: Oct 2011
Posts: 4
It's kinda funny it takes 3 non-intuitive lines of code to do what used to be 1 line of intuitive code
Although someone on MMOC helped me find the solution, along the way I found the APIInterface addon on curse helpful in fleshing this out

Last edited by Machinelf : 08-08-18 at 10:54 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Map API question to help fix old addon

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off