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 .
×
May your rolls be chill this holiday season!
Create a free account

Script 1 changes do not trigger events for script 2

I'm working on a script to do some minor event driven things. Specifically using (what my GM uses for HP): change:graphic:bar3_value We're using TokenMod to make quick and easy token changes, subtracting from Bar3/HP is the most common. I realized my events don't trigger when I use TokenMod to modify Bar3. When I change it manually it triggers.. Is what I want possible, having a change event trigger when another script is making the change? I'm not finding much for this specific scenario and customizing TokenMod in our campaign doesn't seem like the best way to go.
1478430862
Lithl
Pro
Sheet Author
API Scripter
sendChat can trigger chat:message events (likely because sendChat is asynchronous), but beyond that an API function will not trigger an API event. Your only option is to call a function in script 2 from script 1's event.
1478438566
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
In addition to Brian's thorough answer (I had always wondered about why API messages triggered an event) the wiki will become your best friend if you plan to dive any further into scripting:&nbsp;<a href="https://wiki.roll20.net/API:Events" rel="nofollow">https://wiki.roll20.net/API:Events</a>
1478473856
The Aaron
Pro
API Scripter
Also, I think I made a version of TokenMod that allowed registering for events from it. I'll see if I can dig that up tomorrow...
Brian said: sendChat can trigger chat:message events (likely because sendChat is asynchronous), but beyond that an API function will not trigger an API event. Your only option is to call a function in script 2 from script 1's event. Not the only option. They could also use&nbsp;on("chat:message" in their script and listen for the same token mod commands. Then pull the information from that for their script without affecting tokenmod.
Some things came up and I haven't had as much time to spend as I would like working on it, but I'm thinking of going with the chat:message one or if The Aaron has the TokenMod that allows event registering. It's all relatively new to me, so it's taking me some time to parse through documentation etc. and understand how to make it all do what I want.
1478657252
The Aaron
Pro
API Scripter
Cool. I can get you a version that allows registration.&nbsp;
1478727599
The Aaron
Pro
API Scripter
OK, big updates including API Notifications: &nbsp; <a href="https://app.roll20.net/forum/post/4225825/script-u" rel="nofollow">https://app.roll20.net/forum/post/4225825/script-u</a>...
Thank you very much, I really appreciate it.
Just tested it out, works great. Thanks again.
1478745554
The Aaron
Pro
API Scripter
Good deal!