WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Getting ZoneId from GetMapInfo (https://www.wowinterface.com/forums/showthread.php?t=59031)

Firesong 01-31-22 08:05 AM

Getting ZoneId from GetMapInfo
 
Hello all,

I am new to WoW Lua and having issues with getting Zone Ids.

The documentation I am using is here: https://wowpedia.fandom.com/wiki/API...BestMapForUnit

This is the code in macro form:
/run local mapID = C_Map.GetBestMapForUnit("player"); print(format("You are in %s (%d)", C_Map.GetMapInfo(mapID).name, mapID))

When I do this in Northshire the output is "You are in Northshire (425)" but I want to get Elwynn Forest (34) and I can't.

Has the API changed in some way that means the wowhead zone ids are no longer correct?

All help appreciated.

Fizzlemizz 01-31-22 09:15 AM

Northshire is it's own map and the parent map is Elwyn so:

Code:

/run local mapID = C_Map.GetBestMapForUnit("player"); print(format("You are in %s (%d)", C_Map.GetMapInfo(C_Map.GetMapInfo(mapID).parentMapID).name, mapID))
I didn't adjust the mapID so it will still say 425.

Firesong 01-31-22 10:32 AM

Many thanks.

Kanegasi 01-31-22 05:04 PM

The following command will always print the name and ID of the main zone you are in, except for edge cases like swimming in open ocean, where it should report the continent instead:

/run local c,i,m=C_Map.GetMapInfo i=c(C_Map.GetBestMapForUnit("player")) m=i.mapID while i.mapType>3 do i=c(m) m=i.mapID end print("You are in "..i.name.." ("..m..")")


All times are GMT -6. The time now is 10:24 PM.

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