Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Check for removal of specific status marker?

1599267212

Edited 1599267645
Hi, as a foreword I'm not super experienced with javascript or the api, but I've been reading up a bit. I've been wanting to make a specific script which tints a token gray when they are marked with a hidden status marker, and un-tint that token when the status marker is removed. It's pretty easy to do the first part, I check the "change:graphic:statusmarkers" event and then grab the status list and check for the hidden status marker. But is it possible to check for which status marker was removed so I can do the second part? I don't want to remove any tint if the marker wasn't present because I don't want to remove tints from creatures who have a tint for a different reason.
1599283098
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, there are two objects that are passed from an event. The current roll20 object, and the previous state. Note that the previous state is a standard javascript object, as opposed to a roll20 Object like the current state of the object. You can use this like so (very basic example): on('change:graphic:statusmarkers',(obj,prev)=>{ log(obj.get('name')); log(prev.name); }); More details in the wiki
Cool, that’s just the kind of thing I was looking for. Thank you very much, Scott.