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

Conflict between HoneyBadgers's Alter Token and Status

Alterbar: <a href="https://app.roll20.net/forum/post/1216260/script-alter-bar-on-token" rel="nofollow">https://app.roll20.net/forum/post/1216260/script-alter-bar-on-token</a> Status Script /** * Set various token markers based on bar cur/max ratios * * The CONFIG array can have any number of configuration objects. These objects * are processed in order. * * barId - The ID of the bar to look at the values for [1, 2, 3] * barRatio - The ratio of bar value to max value that triggers setting the status marker [0 - 1] * status - The name of the status marker to toggle [redmarker, bluemarker, greenmarker, brownmarker, purplemarker, dead] * whenLow - The state of the marker when the bar value is &lt;= the ratio [true, false] */ var CONFIG = [ // {barId: 1, barRatio: .5, status: "redmarker", whenLow: true}, {barId: 1, barRatio: 0, status: "dead", whenLow: true}]; on("change:token", function(obj) { CONFIG.forEach(function(opts) { var maxValue = parseInt(obj.get("bar" + opts.barId + "_max")); var curValue = parseInt(obj.get("bar" + opts.barId + "_value")); //log(opts.barId + ": " + curValue + "/" + maxValue); if (maxValue != NaN && curValue != NaN) { var markerName = "status_" + opts.status; if (curValue &lt;= (maxValue * opts.barRatio)) { obj.set(markerName, opts.whenLow); } else { obj.set(markerName, !opts.whenLow); } } }); }); When using both scripts, manually adjusting a bar to 0, throws the "dead" staus on it. When using alter bar to lower a bar to 0, the "dead" status does not appear. Can anyone spot the conflict?
1423887497
The Aaron
Pro
API Scripter
AH.. Ok. sorry. I misunderstood your original post and the problem. There isn't a conflict directly, it has to do with the way that the event system works. on( &lt;event&gt;, &lt;callback&gt;); registers a function to be executed whenever a particular event occurs. In this case, it's the "change:token" event. That event is triggered whenever a token is changed by a client . In the case of using the Alterbar script, it isn't a client that is changing it, so the event is not triggered. I ran into a similar problem with my marks script wanting to clear on the turn order changing, but I was changing it programmatically with a !eot command. I solved it in my case by just having my !eot command execute a clear operation on my marks script. That isn't the ideal way of doing it, but the ideal way of doing it is quite a bit of work. I've worked out most of a system for doing it, but haven't written it yet.