Quantcast Current WorldMap Zone Text - WoWInterface
Thread Tools Display Modes
10-15-14, 02:41 PM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Current WorldMap Zone Text

How can i get the current continent/zone text which is currently shown by the map?
  Reply With Quote
10-15-14, 03:15 PM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Have you looked at WorldMapFrame.xml?

WorldMapZoneInfo might be the FontString you want.
  Reply With Quote
10-15-14, 03:22 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,218
GetMinimapZoneText() will get the current zone text.

If you want to update it while moving, use events:

PLAYER_ENTERING_WORLD
ZONE_CHANGED
ZONE_CHANGED_INDOORS
ZONE_CHANGED_NEW_AREA

Edit: You can also use GetZonePVPInfo() to get the zone type, sanctuary, contested, friendly, hostile, arena.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-15-14 at 03:24 PM.
  Reply With Quote
10-15-14, 03:36 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Lua Code:
  1. local function GetMapName()
  2.     local mapName, _, _, isMicroDungeon, microDungeonMapName = GetMapInfo()
  3.     local name = WORLD_MAP
  4.     if GetCurrentMapZone() > 0 then
  5.         name = GetMapNameByID(GetCurrentMapAreaID())
  6.         local floorNum = DungeonUsesTerrainMap() and GetCurrentMapDungeonLevel() - 1 or GetCurrentMapDungeonLevel()
  7.         if floorNum > 0 then
  8.             name = name .. ': ' .. _G["DUNGEON_FLOOR_" .. strupper(mapName or '') .. floorNum]
  9.         end
  10.     else
  11.         local currentContinent = GetCurrentMapContinent()
  12.         if currentContinent ~= WORLDMAP_WORLD_ID and currentContinent ~= WORLDMAP_COSMIC_ID then
  13.             name = select(currentContinent, GetMapContinents())
  14.         end
  15.     end
  16.     return name or (isMicroDungeon and microDungeonMapName or mapName)
  17. end

Last edited by semlar : 10-15-14 at 03:42 PM.
  Reply With Quote
10-15-14, 03:39 PM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by Fizzlemizz View Post
GetMinimapZoneText() will get the current zone text.

If you want to update it while moving, use events:

PLAYER_ENTERING_WORLD
ZONE_CHANGED
ZONE_CHANGED_INDOORS
ZONE_CHANGED_NEW_AREA

Edit: You can also use GetZonePVPInfo() to get the zone type, sanctuary, contested, friendly, hostile, arena.
That returns the player's zone, i need the zone which is shown on the map, not the minimap.
  Reply With Quote
10-15-14, 03:44 PM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by semlar View Post
Lua Code:
  1. local function GetMapName()
  2.     local mapName, _, _, isMicroDungeon, microDungeonMapName = GetMapInfo()
  3.     local name = WORLD_MAP
  4.     if GetCurrentMapZone() > 0 then
  5.         name = GetMapNameByID(GetCurrentMapAreaID())
  6.         local floorNum = DungeonUsesTerrainMap() and GetCurrentMapDungeonLevel() - 1 or GetCurrentMapDungeonLevel()
  7.         if floorNum > 0 then
  8.             name = name .. ': ' .. _G["DUNGEON_FLOOR_" .. strupper(mapName or '') .. floorNum]
  9.         end
  10.     else
  11.         local currentContinent = GetCurrentMapContinent()
  12.         if currentContinent ~= WORLDMAP_WORLD_ID and currentContinent ~= WORLDMAP_COSMIC_ID then
  13.             name = select(currentContinent, GetMapContinents())
  14.         end
  15.     end
  16.     return name or (isMicroDungeon and microDungeonMapName or mapName)
  17. end
Sexy that what i need, thanks.
Shame Blizzard doesn't have a global function something like this.
  Reply With Quote
10-15-14, 03:51 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
I pulled that out of my map function that just sort of returns everything about the current map, "name" can't not exist at the end of the function unless you remove "= WORLD_MAP" from the top of it, so the last part isn't really necessary.

It depends on what you want it to default to if the current map has no name from the other methods.

It also concats the floor name from multi-level maps to the parent map name, so if you want to change that behavior you'll have to edit the floorNum > 0 part.
  Reply With Quote
10-15-14, 03:56 PM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by semlar View Post
I pulled that out of my map function that just sort of returns everything about the current map, "name" can't not exist at the end of the function unless you remove "= WORLD_MAP" from the top of it, so the last part isn't really necessary.

It depends on what you want it to default to if the current map has no name from the other methods.

It also concats the floor name from multi-level maps to the parent map name, so if you want to change that behavior you'll have to edit the floorNum > 0 part.
I actually use this for note handling.
  Reply With Quote
12-05-14, 08:54 AM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
I have some issues specially with the new Zone Names.

Since "Nagrand" and "Shadowmoon Valley" are also exists on Outland, the function save values from both zone into the same table.

Any way to properly differentiate these zones? Or i'm gonna need to slap the zone id into the string?
  Reply With Quote
12-05-14, 09:18 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Names are a really bad way to identify zones. You should be storing map IDs, not names. If you need to display something to the user, you can use GetMapNameByID to get the correct name when needed.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
12-05-14, 03:37 PM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by Phanx View Post
Names are a really bad way to identify zones. You should be storing map IDs, not names. If you need to display something to the user, you can use GetMapNameByID to get the correct name when needed.
I know, but the saved variables force me to do it, and i don't have time to write a proper conversion tool atm.
  Reply With Quote
12-05-14, 06:05 PM   #12
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,923
Originally Posted by Resike View Post
I know, but the saved variables force me to do it...
How so? If you don't know how to wipe saved data, here's a couple commands you can use.

Code:
/run MySavedVar=nil
/reload
Setting your saved variable to nil effectively wipes it out and lets the addon reinitialize to its defaults. This requires a UI reload in order to apply.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-05-14, 09:58 PM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Resike View Post
I know, but the saved variables force me to do it, and i don't have time to write a proper conversion tool atm.
For a one-time conversion of key names in a saved variables table, you really don't need a "proper conversion tool"... just do it quick and dirty, and don't worry about efficiency, because it doesn't matter in this context:

Code:
local function FindMapID(name)
     for i = 1, 1200 do
          if GetZoneNameByID(i) == name then
               return i
          end
     end
end

for k, v in pairs(db) do
    if type(k) == "string" then
         local id = FindMapID(k)
         if id then
              db[id] = v
              db[k] = nil
         else
              print("ERROR: no mapID found for zone name:", k)
         end
     end
end
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
12-07-14, 07:47 AM   #14
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by Phanx View Post
For a one-time conversion of key names in a saved variables table, you really don't need a "proper conversion tool"... just do it quick and dirty, and don't worry about efficiency, because it doesn't matter in this context:

Code:
local function FindMapID(name)
     for i = 1, 1200 do
          if GetZoneNameByID(i) == name then
               return i
          end
     end
end

for k, v in pairs(db) do
    if type(k) == "string" then
         local id = FindMapID(k)
         if id then
              db[id] = v
              db[k] = nil
         else
              print("ERROR: no mapID found for zone name:", k)
         end
     end
end
To be honest after i started thinking about it how could i do it, i ended up with a very similar method.
My question is that is that 1200 max value for the loop is gonna be enough?
  Reply With Quote
12-07-14, 09:13 AM   #15
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 762
http://wowpedia.org/MapID
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
12-07-14, 08:28 PM   #16
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, I specifically picked 1200 by looking at the list of mapIDs and determining that none are above 1200. Since this is a one-time process, and not something that needs to be future-proof, the fact that future content patches and expansions might add maps with IDs higher than 1200 isn't relevant.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
12-08-14, 08:39 AM   #17
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
You could also just use GetAreaMaps() for a list of map ids, if you're into that sort of thing.
  Reply With Quote
12-11-14, 11:37 AM   #18
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by semlar View Post
You could also just use GetAreaMaps() for a list of map ids, if you're into that sort of thing.
Nice, how did i missed that function?
  Reply With Quote
12-11-14, 02:42 PM   #19
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,109
Originally Posted by Resike View Post
Nice, how did i missed that function?
I believe it is new to 6.x. There is also GetAreaMapInfo() but so far neither has been documented.
  Reply With Quote
12-11-14, 05:22 PM   #20
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by myrroddin View Post
I believe it is new to 6.x. There is also GetAreaMapInfo() but so far neither has been documented.
It was in the MoP beta, people are just too lazy to document things.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Current WorldMap Zone Text

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