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

Two events triggered from change:graphic:bar1_value

Good evening, I am seeing two events being triggered from the on('change:graphic:bar1_value'....), is it due to the change:attribute and then the change:graphic? I would rather receive one and output one. I read this,. In addition, when the Attribute (or token bar) is modified in-game, you will hear a change:attribute (and property-specific, e.g. change:attribute:current ) event, followed by a change:graphic (and change:graphic:bar1_value ) event. You can choose to respond to either event, but the underlying bar values will not yet be updated when the attribute event fires, since it fires first.
1586221158
The Aaron
Roll20 Production Team
API Scripter
It's probably because of the attribute it's tied to changing.  You can wrap your handler in  _.debounce()  to prevent it from triggering multiple times. on('change:graphic',_.debounce((obj,prev)=>{ /* do things with the event */ }));
The Aaron said: It's probably because of the attribute it's tied to changing.  You can wrap your handler in  _.debounce()  to prevent it from triggering multiple times. on('change:graphic',_.debounce((obj,prev)=>{ /* do things with the event */ })); Works great! Thank you!
1586303489
The Aaron
Roll20 Production Team
API Scripter
Cool.  =D