View Single Post
05/11/22, 06:05 AM   #5
IsJustaGhost
AddOn Author - Click to view addons
Join Date: May 2020
Posts: 38
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.