bmos
August 26th, 2021, 17:40
I'm having an issue using Token.onAdd as a way of triggering an event whenever a token is dragged onto the map.
I use this exact method with Token.onMove and it works great. Any suggestions how I can make this work?
It debugs as nil when dragging token to the map. I have checked for token.getContainerNode() and token.getId() and they both return values, so I think the issue is with CombatManager.getCTFromTokenRef not being able to find the token on that map using its id.
local onAdd = nil;
local function auraOnAdd(tokenInstance)
if onAdd then
onAdd(tokenInstance);
end
if Session.IsHost then
Debug.chat(CombatManager.getCTFromToken(tokenInsta nce))
end
end
function onInit()
onAdd = Token.onAdd
Token.onAdd = auraOnAdd
end
I use this exact method with Token.onMove and it works great. Any suggestions how I can make this work?
It debugs as nil when dragging token to the map. I have checked for token.getContainerNode() and token.getId() and they both return values, so I think the issue is with CombatManager.getCTFromTokenRef not being able to find the token on that map using its id.
local onAdd = nil;
local function auraOnAdd(tokenInstance)
if onAdd then
onAdd(tokenInstance);
end
if Session.IsHost then
Debug.chat(CombatManager.getCTFromToken(tokenInsta nce))
end
end
function onInit()
onAdd = Token.onAdd
Token.onAdd = auraOnAdd
end