View Single Post
04/10/14, 12:01 PM   #2
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
Lua Code:
  1. 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:
  1. function(pinManager)
  2.     for _, harvestNode in pairs( myHarvestNodes ) do
  3.         pinManager:CreatePin( _G["Xrystal_Wood"], harvestNode, harvestNode.x, harvestNode.y)
  4.     end
  5. 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:
  1. { texture = 'MyAddon/niceTexture.dds', level = 20, size = 30 }


pinTooltipCreator is another table which handles the tooltip obviously.
example:
Lua Code:
  1. {
  2.     creator = function( pin )
  3.         InformationTooltip:AddLine( pin.m_PinTag.tooltip )
  4.     end,
  5.     tooltip = InformationTooltip
  6. }
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:
  1. 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:
  1. ZO_WorldMap_RefreshCustomPinsOfType( _G[pinType] )
or
Lua Code:
  1. ZO_WorldMap_RefreshCustomPinsOfType()
if you want to refresh all pin types




now back to your code:
Lua Code:
  1. local pinType = v.Name
  2.             local pinID = i
  3.             local drawCallback = function() XMPins:RefreshCustomPins(pinType) end
  4.             local resizeCallback = function() XMPins:RefreshCustomPins(pinType) end    
  5.             local pinLayoutData = {}
  6.             for i,v in pairs(XMPins.Layout) do
  7.                 pinLayoutData[i] = v
  8.             end
  9.             pinLayoutData.texture = TradeSkills[pinID].Icon
  10.             local pinTooltipCreator = { creator = function(pin) InformationTooltip:AddLine(TradeSkills[pinID].skillName) end, tooltip = InformationTooltip }
  11.             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

Last edited by Shinni : 04/10/14 at 12:06 PM.
  Reply With Quote