Lua Code:
ZO_WorldMap_AddCustomPin(pinType, drawCallback, resizeCallback, pinLayout, pinTooltipCreator)
pinType should be a unique name for your pin type.
eg "Xrystal_Wood" if you want this pin type to represent wood harvest nodes for your gatherer.
drawCallback is a function which receives a pin manager as argument. this function is called wenever the map is drawn. it's supposed to create your map pins eg:
Lua Code:
function(pinManager)
for _, harvestNode in pairs( myHarvestNodes ) do
pinManager:CreatePin( _G["Xrystal_Wood"], harvestNode, harvestNode.x, harvestNode.y)
end
end
note that zenimax's scripts internally use integers for pinTypes. the internal representation of the pin type "Xrystal_Wood" is saved in _G["Xrystal_Wood"].
the second argument of CreatePin is the pintag. you can use this to pass additional informations to later layout/tooltip functions
resizeCallback is called whenever the map size changes, eg when the player zooms in.
I always use nil as normal pins don't need to resize.
this function gets 2 arguments: the new width and height.
pinLayout is a table which represents the layout of all pins of this pin type
it needs a key called
texture for the pin texture, a key called
level which determines which pin is drawn above the other. it can also have an optinal key called
size.
example:
Lua Code:
{ texture = 'MyAddon/niceTexture.dds', level = 20, size = 30 }
pinTooltipCreator is another table which handles the tooltip obviously.
example:
Lua Code:
{
creator = function( pin )
InformationTooltip:AddLine( pin.m_PinTag.tooltip )
end,
tooltip = InformationTooltip
}
tooltip says, which tooltip window is to be used (don't know what other there are besides of InformationTooltip)
creator is a function which receives the pin and adds text to the tooltip. remember the pinTag (2nd argument of pinManager:CreatePin)? here you can use the additional data via pin.m_PinTag
to enable a pin call
Lua Code:
ZO_WorldMap_SetCustomPinEnabled(_G[pinType], bool )
remember to use _G[pinType]!
if you want to refresh the pins (because you changed layout information or something like that) call
Lua Code:
ZO_WorldMap_RefreshCustomPinsOfType( _G[pinType] )
or
Lua Code:
ZO_WorldMap_RefreshCustomPinsOfType()
if you want to refresh all pin types
now back to your code:
Lua Code:
local pinType = v.Name
local pinID = i
local drawCallback = function() XMPins:RefreshCustomPins(pinType) end
local resizeCallback = function() XMPins:RefreshCustomPins(pinType) end
local pinLayoutData = {}
for i,v in pairs(XMPins.Layout) do
pinLayoutData[i] = v
end
pinLayoutData.texture = TradeSkills[pinID].Icon
local pinTooltipCreator = { creator = function(pin) InformationTooltip:AddLine(TradeSkills[pinID].skillName) end, tooltip = InformationTooltip }
XMPins:AddCustomPin(pinType,drawCallback,resizeCallback,pinLayoutData,pinTooltipCreator,pinID)
i'd expect a buffer overflow here.
drawCallback is called when the map is refreshed but your drawCallback forces the map to refresh again.
the only reason your game didn't crash is because you didn't use _G[pinType] in the XMPins:RefreshCustomPins argument