Based on Garkin's awesome script (Big kudos).
lua Code:
-- Based on Garkin's Guide
-- [url]https://www.esoui.com/forums/showthread.php?t=1557[/url]
local ZGESO = {}
-- Pin's unique ID
ZGESO.pinType = "MyMapPin"
-- Pin Data
ZGESO.pinLayoutData = {
{ level = 50, texture = "/Arrows/Stealth/arrow-error.dds", size = 40 },
}
-- Unit test sample data
ZGESO.pinData = {
["alikr"] = {
["sentinel_base"] = {
{ x = 0.130820446, y = 0.378319359 },
},
},
}
-- Tooltip Creator
ZGESO.pinTooltipCreator = {
creator = function(pin)
local x, y = pin:GetNormalizedPosition()
InformationTooltip:AddLine( zo_strformat( "Position of my pin is: <<1>>,<<2>>", x*1000, y*1000 ) )
end,
tooltip = InformationTooltip,
}
-- Add a Callback Function
function ZGESO.pinTypeAddCallback(pinManager)
-- Do not create pins if your pinType is not enabled
if not ZO_WorldMap_IsCustomPinEnabled(_G[ZGESO.pinType]) then return end
-- Do not create pins on world, alliance and cosmic maps
if (GetMapType() > MAPTYPE_ZONE) then return end
-- Okay to continue
local textureName = GetMapTileTexture()
textureName = string.lower(textureName)
local _,_,_,zone,subzone = string.find(textureName, "(maps/)([%w%-]+)/([%w%-]+_%w+)")
local pins
print(zone, subzone)
if ZGESO.pinData[zone] and ZGESO.pinData[zone][subzone] then
pins = ZGESO.pinData[zone][subzone]
else
return -- Return if there's no current map data
end
for _, pinInfo in ipairs(pins) do
-- ZO_WorldMapPins:CreatePin(pinTypeId, pinTag, locX, locY, areaRadius)
-- pinTag can be anything, but I recommend using table or string with additional info about pin, you can use it later in code
pinManager:CreatePin(_G[ZGESO.pinType], pinInfo, pinInfo.x, pinInfo.y)
end
end
-- Resize callback function (usualy just nil)
function ZGESO.pinTypeOnResizeCallback(pinManager, mapWidth, mapHeight)
local visibleWidth, visibleHeight = ZO_WorldMapScroll:GetDimensions()
local currentZoom = mapWidth / visibleWidth
if currentZoom < 1.5 then
ZO_WorldMap_SetCustomPinEnabled(_G[ZGESO.pinType], false)
else
ZO_WorldMap_SetCustomPinEnabled(_G[ZGESO.pinType], true)
end
ZO_WorldMap_RefreshCustomPinsOfType(_G[ZGESO.pinType])
end
function OnLoad(eventCode, name)
-- The name of this addon
if name ~= "ZGESO" then return end
-- Initialize map pins
ZO_WorldMap_AddCustomPin(ZGESO.pinType, ZGESO.pinTypeAddCallback, ZGESO.pinTypeOnResizeCallback, ZGESO.pinLayoutData, ZGESO.pinTooltipCreator)
-- Custom pins are disabled by default, you have to enable them
ZO_WorldMap_SetCustomPinEnabled(_G[ZGESO.pinType], true)
-- Force refresh pins to call pinTypeAddCalback for the current map
ZO_WorldMap_RefreshCustomPinsOfType(_G[ZGESO.pinType])
EVENT_MANAGER:UnregisterForEvent("ZGESO_OnLoad", EVENT_ADD_ON_LOADED)
end
EVENT_MANAGER:RegisterForEvent("ZGESO_OnLoad", EVENT_ADD_ON_LOADED, OnLoad)
It looks like the code works but there's a problem with the level value in ZO_MapPin.SetData?
https://esodata.uesp.net/100025/src/....lua.html#3347
lua Code:
bad argument #1 to 'math.max' (number expected, got nil)
stack traceback:
[C]: in function 'math.max'
EsoUI/Ingame/Map/WorldMap.lua:3347: in function 'ZO_MapPin:SetData'
<Locals> self = tbl, pinType = 206, pinTag = tbl, control = ud, labelControl = ud, singlePinData = tbl, overlayControl = ud, highlightControl = ud </Locals>
EsoUI/Ingame/Map/WorldMap.lua:3687: in function 'ZO_WorldMapPins:CreatePin'
<Locals> self = tbl, pinType = 206, pinTag = tbl, xLoc = 0.130820446, yLoc = 0.378319359, pin = tbl, pinKey = 71 </Locals>
user:/AddOns/ZGESO/Pointer.lua:181: in function 'ZGESO.pinTypeAddCallback'
<Locals> pinManager = tbl, textureName = "art/maps/alikr/sentinel_bas...", _ = 5, _ = 28, _ = "maps/", zone = "alikr", subzone = "sentinel_base", pins = tbl, _ = 1, pinInfo = tbl </Locals>
EsoUI/Ingame/Map/WorldMap.lua:3667: in function 'ZO_WorldMapPins:RefreshCustomPins'
<Locals> self = tbl, pinTypeId = 206, pinData = tbl </Locals>
EsoUI/Ingame/Map/WorldMap.lua:6100: in function 'ZO_WorldMap_UpdateMap'
<Locals> zoneName = "Sentinel", mapTitle = "Sentinel" </Locals>
user:/AddOns/ZGESO/Viewer/GuideViewerFrame.lua:1095: in function 'Viewer:HandleActionLayer'
<Locals> self = tbl, isActive = [C]:-1 </Locals>
user:/AddOns/ZGESO/Viewer/GuideViewerFrame.lua:1133: in function 'Viewer:EVENT_ACTION_LAYER_POPPED'
<Locals> self = tbl, event = 65553, layerIndex = 7, activeLayerIndex = 2 </Locals>
user:/AddOns/ZGESO/Events.lua:58: in function 'EventHandler'
<Locals> event = 65553, self = tbl, eventString = "EVENT_ACTION_LAYER_POPPED", _ = 1, hand = tbl, func = user:/AddOns/ZGESO/Viewer/GuideViewerFrame.lua:1131, funcSelf = tbl </Locals>
Extra information:
1. The pinLayoutData array has a value for level.
2. The print(zone, subzone) on line 45 splits out what appears to be an endless list of zone, subzone. My conclusion is there needs to be a max value to stop it from overloading ZO_MapPin.SetData. Is that causing the problem?
3. An observational finding
https://i.imgur.com/SpnGhqf.png