Originally Posted by votan
<emperor>Welcome on the dark side</emperor>
You are right, size is used as a value, only. By default. But by the power of Lua you can intercept accessing properties like "size" to change the returned value dynamically.
For example:
Lua Code:
function addon:HookPOIPins() local GetCurrentMapIndex = GetCurrentMapIndex local function HookPinSize(data) local orgMetaTable = getmetatable(data) local orgSize = data.size or 40 data.size = nil -- Force to ask the metatable local newMetaTable = {} setmetatable(newMetaTable, orgMetaTable) local alter = {} alter.size = function() return GetCurrentMapIndex() == 1 and 1 or orgSize end -- more alternates here newMetaTable.__index = function(data, key) return alter[key] and alter[key](data) or newMetaTable[key] -- if alternate exists, call it end newMetaTable.__newindex = function(data, key, value) if key == "size" then orgSize = value return -- Do not set value within table to keep using metatable end return rawset(data, key, value) end setmetatable(data, newMetaTable) end HookPinSize(ZO_MapPin.PIN_DATA[MAP_PIN_TYPE_FAST_TRAVEL_WAYSHRINE]) HookPinSize(ZO_MapPin.PIN_DATA[MAP_PIN_TYPE_FAST_TRAVEL_WAYSHRINE_CURRENT_LOC]) end
Of course you have to adapt this to your needs.
|
How could I get the players unit tag from this? In your addon you set the texture and color to a function that takes the pin as the parameter and gets the unit tag from that. Is there a similar way to achieve this with the hook?