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

Trying to get Status FX Script to work with Bloodied and Dead Status Markers

<a href="https://wiki.roll20.net/Script:Bloodied_and_Dead_S" rel="nofollow">https://wiki.roll20.net/Script:Bloodied_and_Dead_S</a>... Is the second script im refering to. Right now with Status FX you have to manually click the red icon for blood to spurt out. can anyone help me out?
1471612380

Edited 1471612564
Ada L.
Marketplace Creator
Sheet Author
API Scripter
StatusFX operates by receiving events about tokens' status markers being changed. The way that the API is set up though, events aren't fired if the status is changed programmatically. I imagine that this is done in part to avoid infinite event loops in the API. To get around this, I've exposed an updateTokenState method in StatusFX that you can call from your script sort of like this: (function() { &nbsp; &nbsp; function updateFort(token) { &nbsp; &nbsp; &nbsp; &nbsp; if(token.get("bar1_max") === "" || !token.get('represents'))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token.get("bar1_value") &lt;= token.get("bar1_max") / 2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_green: true }); &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_green: false }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateSidelined(token); &nbsp; &nbsp; &nbsp; &nbsp; StatusFX.updateTokenState(token); // Apply the bleeding FX if the green marker is on. &nbsp; &nbsp; } &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; function updateWill(token) { &nbsp; &nbsp; &nbsp; &nbsp; if(token.get("bar2_max") === "" || !token.get('represents'))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token.get("bar2_value") &lt;= token.get("bar2_max") / 2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_blue: true }); &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_blue: false }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateSidelined(token); &nbsp; &nbsp; &nbsp; &nbsp; StatusFX.updateTokenState(token); // Apply the fear FX if the blue marker is on. &nbsp; &nbsp; } &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; function updateSidelined(token) { &nbsp; &nbsp; &nbsp; &nbsp; if(token.get("bar1_value") &lt;= 0 || token.get("bar2_value") &lt;= 0) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_dead: true }); &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token.set({ status_dead: false }); &nbsp; &nbsp; } &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; on('change:graphic:bar1_value', updateFort); &nbsp; &nbsp; on('change:graphic:bar1_max', updateFort); &nbsp; &nbsp; on('change:graphic:bar2_value', updateWill); &nbsp; &nbsp; on('change:graphic:bar2_max', updateWill); })(); You'll need to manually edit your script to stick StatusFX.updateTokenState(token); in there somewhere after you update your red and dead marker status.
Okay yeah I have no idea how to add that in. My ability to program is 0
1471617345
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I'll see about setting up an interval for it to automatically update its state in a future update then.
1471638244
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I just put a pull request in to better automate status marker detection. You can expect your issue to be resolved in version 1.2.
That's amazing. Thank you