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.
C
caewok36d 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
S
StagnuDemorte35d 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.
LTL
Leo The League Lion35d ago
@StagnuDemorte gave :vote: LeaguePoints™ to @caewok (#38 • 76)
Want results from more Discord servers?
Add your server
More Posts
GitHub Actions on releaseHi there, hope I'm at the right place. I'm actually new to actions on GitHub, trying for release- dUsing an array in a sheet templateIn the system I am creating, the progression of a skill category is handled with a fixed size array hook preCreateToken update token nameI'm trying to update the token name when dropping a token on a scene. I basically have something lempty packSo I'm trying to access a pack in my module and it does exist but it's empty. My thoughts are 1. TError on package installError message ``` Error: Cannot read properties of null (reading 'protected') ``` I've started up Absolutely new to all of this, need help with a silly query.Hello! I'm extremely new to all of this, and i'm having issues trying to understand how to code a waHi, friends! I'd like to build a moduleHi, friends! I'd like to build a module and I could use a shove in the right part of the docs to go Well now I'm downloading lancerWell now I'm downloading lancerNew Entertainer - Fantasy if not Table Top ---- yetMy grandson is 11, and he has started making video shorts. This is his first full length YouTube stBoilerplate.css fileHi I started a new system from the Boilerplate system, and am having an issue seeing updates from myNewbie question on scopeHey there, total newbie here. I'm a complete amateur to programming. I've completed the todo tutoriaHaving trouble to get scripts loadedTrying to make my first module and I have troubles getting anything loaded in Foundry. Here is what