change token lighting based on changing value on actor or an Effect embedded on the actor.

I'm attempting to add a feature to my system that makes the token glow when it's lightsaber/generic laser sword is ignited. I was able to make a custom token document class that can override the light settings, but that only updates the light settings on refresh or move. is there some way to trigger a redraw or is there a better place to implement this logic? maybe i should make a custom token class.
Solution:
Thanks for your response. that resembles my first attempt. what ended up working is overriding the _onUpdateDescendantDocuments method on the token document, resetting the tokenDoc, then calling updateLightSource on the token itself. i think i had to override the _onUpdateDescendantDocuments on the actor as well to make sure it picked up the changes.
Jump to solution
3 Replies
caewok
caewok8mo ago
You probably want token.renderFlags.set({redraw:true}). But check out the other flags, because you might be able to get away with something more specific rather than a full redraw. I doubt you need a full subclass, although you might want it for other reasons if you are designing a system. You can hook token update or preupdate to see when a token moves or will move, and change light settings in response to that.
Solution
StagnuDemorte
StagnuDemorte8mo ago
Thanks for your response. that resembles my first attempt. what ended up working is overriding the _onUpdateDescendantDocuments method on the token document, resetting the tokenDoc, then calling updateLightSource on the token itself. i think i had to override the _onUpdateDescendantDocuments on the actor as well to make sure it picked up the changes.
Leo The League Lion
@StagnuDemorte gave :vote: LeaguePoints™ to @caewok (#38 • 76)
Want results from more Discord servers?
Add your server