Quantcast
Download
(10 Kb)
Download
Updated: 07/31/22 09:29 AM
Compatibility:
Lost Depths (8.1.5)
Updated:07/31/22 09:29 AM
Created:04/25/22 09:08 PM
Monthly downloads:64,950
Total downloads:186,375
Favorites:221
MD5:
LibMapData  Popular! (More than 5000 hits)
Version: 1.04
by: Sharlikran [More]
Intent

For my use case I need one central mod to control the map information of where the player is. I don't want to call SetMapToPlayerLocation() and CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged") at various times in 5 mods.

With this library used as a dependency for the intended mods, FireCallbacks:OnWorldMapChanged is only used when GetMapTileTexture() changes. This reduces the chance that the mods it is used with are changing the map too frequently.

Grated SetMapToPlayerLocation() is called when the player closes the map and for events EVENT_ZONE_CHANGED, EVENT_LINKED_WORLD_POSITION_CHANGED, and EVENT_PLAYER_ACTIVATED to make sure the map information is current.

However, it happens within the library not the mods that depend on it resulting in fewer calls to those API commands for maps.

Intended use, for now

This will be used eventually with Destinations, Quest Map, LibQuestData, Skyshards, Lorebooks, and ScrySpy.

You could use it to convert a zoneId, mapIndex, or texture name mod to mapIds only. Although some map names and textures have multiple mapIds. You would have to manually convert anything that has multiple mapIds.

Current State

Work in progress but since it will be used with 5 mods at least then I will upload it and update it as I go.

Upcoming Additions

A pseudo mapIndex for all the various submaps in a zone. This can be used to gather pins for the entire map all at once. If you format your pin data with proper keys then you can display pins for both the mapId for the city and the zone itself without the need for two pin locations. Only needing a separate pin if the map pin information is from a Delve or Public dungeon where the player is underground.

Possible addition for a specialized scale that will place a map pin from a subZone or Dungeon map on the main zone without the need for additional pin data. This is a current system for Quest Map. The scale is created by measuring the map after placing a player waypoint. Written by CaptainBlagbird for Quest Map.

Also possible API for attaching map pins to the POI using something like GetPOIMapInfo() rather then a scale system as mentioned above. Destinations uses a table for the unknown POI built from the available POIs on the current map. As long as you know which POI you need the pin to be close to then the pin would use the POIs coordinates.

Slash Commands

NOTE: I use the DebugLogViewer's Quick View to see the player location information

/lmdgetpos : Returns the player location information and coordinates

Current API

local LMD = LibMapData

Global Variables

Note: Only use the game API for the x,y coordinates GetMapPlayerPosition("player") and if used with LibGPS then convert the local coordinates to global or whatever you need.

If you need the following access it from LMD

lib.zoneIndex
lib.mapIndex
lib.mapId
lib.zoneId
lib.mapTexture
lib.isMainZone
lib.isSubzone
lib.isWorld
lib.isDungeon
lib.zoneName
lib.mapName
lib.subzoneName
lib.currentFloor
lib.numFloors

If you do any for loops for the mapIndex, mapId, zoneIndex or zoneId you can use the following. This includes High Isle.

lib.MAPINDEX_MIN = 1
lib.MAPINDEX_MAX = 46
lib.MAX_NUM_MAPIDS = 2223
lib.MAX_NUM_ZONEINDEXES = 907
lib.MAX_NUM_ZONEIDS = 1364

for i = 1, lib.MAX_NUM_MAPIDS do
mapName = GetMapNameById(i)
if mapName ~= "" then
<< Do Stuff>>
end
end

Functions

lib:GetMapIdByTileTexture(tileTexture)
Given: String, full texture name of map see lib:GetMapTileTextureFromMapId()
Returns a table of the mapId numbers for that texture name. There can be more the one mapId.

lib:GetMapIdByMapName(mapName)
Given: String, can be obtained with GetMapNameById()
Returns a table of the mapId numbers for the given map name. There can be more the one mapId.

lib:ReturnSingleIndex(indexTable)
Given: Table
Returns a single value from a mapId table such as GetMapIdByMapName(). Returns nil and a LibDebugLogger warning if there is more then one mapId.

lib:GetZoneMapIdFromMapId(mapId)
Given: integer
Returns the mapId for the zone regardless of the map you are on. For example if you are in The Hall of the Dead it will not return the mapId of Windhelm, you will get the mapId for Eastmarch.

lib:GetZoneMapIdFromZoneId(zoneId)
Given: integer
Returns the mapId for the zone regardless of the map you are on. For example if you are in The Hall of the Dead it will not return the mapId of Windhelm, you will get the mapId for Eastmarch.

lib:GetMapTileTextureFromMapId(mapId)
Given: integer
Returns the first tile index from GetMapTileTextureForMapId() for the given mapId for use with GetMapIdByTileTexture() or for use with your mod if you prefer using map textures to mapId.

Callbacks

lib:RegisterCallback()
lib:UnregisterCallback()

lib.callbackType.EVENT_ZONE_CHANGED = "LibMapDataEventZoneChanged"
lib.callbackType.EVENT_LINKED_WORLD_POSITION_CHANGED = "LibMapDataEventLinkedWorldPositionChanged"
lib.callbackType.EVENT_PLAYER_ACTIVATED = "LibMapDataEventPlayerActivated"
lib.callbackType.OnWorldMapChanged = "LibMapDataOnWorldMapChanged"
lib.callbackType.WorldMapSceneStateChange = "LibMapDataWorldMapSceneStateChange"

Lua Code:
  1. local LMD = LibMapData
  2. LMD:RegisterCallback(LMD.callbackType.OnWorldMapChanged,
  3.   function()
  4.     RefreshPins()
  5.   end)
v103

- Pre PTS Version

v103

- Hotfix for version mismatch

v102

- Added RegisterCallback and UnregisterCallback for updating pins or other map related information from LibMapData without the need for the mod to check and verify the map state independently of LibMapData

v101

- Hotfix for: LibMapData.lua:160: table index is nil
Archived Files (4)
File Name
Version
Size
Uploader
Date
1.03
10kB
Sharlikran
05/01/22 02:16 PM
1.02
10kB
Sharlikran
04/30/22 07:20 PM
1.01
9kB
Sharlikran
04/26/22 02:24 AM
1.00
9kB
Sharlikran
04/25/22 09:08 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: