Thread Tools Display Modes
05/14/21, 11:33 PM   #1
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
[implemented] ZO_WorldMap_SetMapById()

Many maps don't have a map index but it looks like all maps have a map ID so :

ZO_WorldMap_SetMapById()

would be of a great help for map / navigation AddOns
e. g. my QuickMapNav AddOn.
 
05/15/21, 06:05 AM   #2
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
There exists the api function SetMapToMapId(mapId), so you could just call the following
Lua Code:
  1. if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  2.     CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3. end
 
05/15/21, 11:43 AM   #3
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
Wow! Thanks I totally missed that!
 
05/15/21, 09:37 PM   #4
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
I added it to the Wiki :
https://wiki.esoui.com/SetMapToMapId
 
05/11/22, 06:05 AM   #5
IsJustaGhost
AddOn Author - Click to view addons
Join Date: May 2020
Posts: 37
There is a SetMapToMapId. However, unless the user changes the map manually first, the map will reset to the on map open default after SetMapToMapId is used. Making it almost useless.

I've proposed this.
Lua Code:
  1. function ZO_WorldMap_SetMapById(mapId)
  2.     if WORLD_MAP_MANAGER:IsMapChangingAllowed() then
  3.         if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  4.             g_playerChoseCurrentMap = true
  5.             CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  6.         end
  7.     end
  8. end

You see, the g_playerChoseCurrentMap must be true in order for the map to not be reset.
Lua Code:
  1. function Update(map, currentTimeS)
  2.         -- ... in short
  3.  
  4.             -- If the player is just wandering around the world, with their map open, then refresh it every so often so that
  5.             -- it's showing the appropriate location for where they are.  If they actually picked a loction, then avoid this update.
  6.             if not g_playerChoseCurrentMap then
  7.                 if SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED then

The alternative is to:
Lua Code:
  1. local original_CALLBACK_MANAGER = CALLBACK_MANAGER
  2. local function setMapById(mapId)
  3.     -- lets prevent the callback from firing when we only want to set g_playerChoseCurrentMap to true
  4.     CALLBACK_MANAGER = {FireCallbacks = function() end}
  5.  
  6.     -- Lets fire this so it will set g_playerChoseCurrentMap to true
  7.     ZO_WorldMap_SetMapByIndex(1)
  8.    
  9.     -- Now reset the callback manager
  10.     CALLBACK_MANAGER = original_CALLBACK_MANAGER
  11.    
  12.     -- Set map by mapId and fire callback
  13.     if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  14.         CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  15.     end
  16. end

Last edited by IsJustaGhost : 05/11/22 at 06:08 AM.
 
05/11/22, 06:44 AM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Or do things a better way and use what is already available which will be more compatible with other mods.
Code:
  local GPS = LibGPS3
  SetMapToMapId(mapId)
  GPS:SetPlayerChoseCurrentMap()
  CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")

Last edited by Sharlikran : 05/11/22 at 07:56 AM.
 
11/01/22, 06:04 PM   #7
IsJustaGhost
AddOn Author - Click to view addons
Join Date: May 2020
Posts: 37
This can be closed.
WORLD_MAP_MANAGER:SetMapById(mapId) exists now
 
11/01/22, 08:00 PM   #8
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Closed and updated the Wiki
 

ESOUI » Developer Discussions » Wish List » [implemented] ZO_WorldMap_SetMapById()

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