Quantcast
Getting ZoneId from GetMapInfo - WoWInterface
Thread Tools Display Modes
01-31-22, 08:05 AM   #1
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 18
Question 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.
  Reply With Quote
01-31-22, 09:15 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,499
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-31-22, 10:32 AM   #3
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 18
Many thanks.
  Reply With Quote
01-31-22, 05:04 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 615
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..")")
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting ZoneId from GetMapInfo

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