Originally Posted by unLeashed3k
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:
local mapName = GetPlayerLocationName()
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:
If map location is changed, you will probably need to redraw map, so better is:
Lua Code:
if(SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED) then
CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
end
And then use:
Lua Code:
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:
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:
local LMP = LibStub("LibMapPins-1.0")
local zone, subzone = LMP:GetZoneAndSubzone()
local zoneName = LMP:GetZoneAndSubzone(true)
See topic:
http://www.esoui.com/forums/showthread.php?t=1431