When can I trigger a addUnderlay after a token is added?
I've run into this ... tail chasing/chicken-egg problem.
The idea is to apply an underlay to a token in various situations.
When token added to image.
When the image is opened.
When effects change.
The problem seems to be that I cannot get it to properly add when the token is added. Either using Token.onAdd() or ImageControl.onTokenAdded().
Token.onAdd() triggers but it doesn't have a CT yet so getCTFromToken() wont work (I need this for effects).
ImageControl.onTokenAdded() has the same problem. Even when dragging from the CT onto the map it cannot find a valid from nodeCT using
local nodeCT = CombatManager.getCTFromToken(tokenCT); (tokenCT is valid).
The kludge I used to get around the image sending all this bogus "addToken()" without having the attached data... well I use Interface.onWindowOpened = onWindowOpened; and check for class imagecontrol. Yup it's ugly but there are no other options right now. Using that I am able to get a imagecontrol thats opened and size isn't 0/0 and the tokens are actually there and have matching nodeCTs.
However, I still need to have something that triggers when the token is added so that if they add a new N/PC that has an aura to the map it'll update the underlay. Right now, there isn't a way to do that.
What I need is some event I can attach to that triggers AFTER the token is placed and AFTER the image is setup and AFTER the nodeCT is connected.
Any such thing?