View Single Post
08/08/14, 04:11 PM   #10
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by unLeashed3k View Post
Q3: Is there a way to get any index (map, zone, subzone) that's reliable to where the character is actively standing in the world or must I set up my own 'key = value' table and check that table against GetPlayerLocationName (which seems to be the only dependable information about where the player is and not what map is being viewed)?
A3: There are two functions which doesn't depend on WorldMap:
Lua Code:
  1. local mapName = GetPlayerLocationName()
  2. local zoneName = GetUnitZone("player")
However both function returns just a localized name which is not uinque. You will have to use something different:

- If you use GetPlayerLocationName(), GetMapName() or GetUnitZone(unitTag) there are duplicate names (check map list on Esohead - http://www.esohead.com/map). Also there are issues with localized names.
- GetCurrentMapZoneIndex() - zone and subzone has the same zone index (subzone = city in the zone)
- GetCurrentMapIndex() works only for maps listed in WorldMap
- GetMapTileTexture() returns "Art/maps/stormhaven/wayrest_base_0.dds". As it is file name it must be unique. Bingo.

At first you have to reset map position, to be sure that you're checking correct location:
Lua Code:
  1. SetMapToPlayerLocation()
If map location is changed, you will probably need to redraw map, so better is:
Lua Code:
  1. if(SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED) then
  2.     CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3. end

And then use:
Lua Code:
  1. local zone, subzone = select(3,(GetMapTileTexture()):lower():find("maps/([%w%-]+)/([%w%-]+_%w+)"))
returns:
zone = "stormhaven"
subzone = "wayrest_base"

or if you want just single location name:
Lua Code:
  1. local zoneName = select(3,(GetMapTileTexture()):lower():find("maps/([%w%-]+/[%w%-]+_%w+)"))
returns:
zone = "stormhaven/wayrest_base"

Or if you are using LibMapPins library, then:
Lua Code:
  1. local LMP = LibStub("LibMapPins-1.0")
  2. local zone, subzone = LMP:GetZoneAndSubzone()
  3. local zoneName = LMP:GetZoneAndSubzone(true)

See topic: http://www.esoui.com/forums/showthread.php?t=1431
  Reply With Quote