Advertisement Create a free account

Removing Token from Turn Tracker automatically when BAR1 value falls below certain value

I'm trying to figure out how to remove a token automatically from the turn tracker when the value of BAR1 falls below a certain level.  I've found numerous examples on how to change status markers and auras when values are within certain ranges, or fall below a certain threshold, however I can't find any good examples of how to remove a token from the turn tracker when this happens.  I was able to find a reference to this on an older thread, but it pointed to a gitHub page that no longer exists, so I was unable to review the code to try and figure it out.  Any help that can be provided would be most appreciated.
1444693527

Edited 1444693571
The Aaron
Forum Champion
API Scripter
It's not as simple as it could be, that's why you are having problems finding good examples. Here's an annotated example that does just what you're asking for: on('ready',function() {     'use strict';      // Threshold to be equal to or less than to get removed     var threshold = 0;       // Activate on a change to the value of bar1     on('change:graphic:bar1_value',function(obj){         var turnorder; // if the value is below or equal         if( obj.get('bar1_value') <= threshold ){ // grab the current turnorder             turnorder = Campaign().get('turnorder'); // if it's the empty string, then just treat it as an array, // otherwise decode it as a JSON string into the array of turns             turnorder = ('' === turnorder) ? [] : JSON.parse(turnorder); // Get a version of it without the token we were activated for             turnorder = _.reject(turnorder, function(i){                 return obj.id === i.id;             }); // encode the array as a JSON string and // stuff it back in the turnorder property of the Campaign             Campaign().set('turnorder',JSON.stringify(turnorder));         }     }); }); Feel free to ask me anything, I'm happy to discuss the API at length!  =D
Awesome!  I always forget to take tokens off the turn order, this will be a big help.
1444732887
The Aaron
Forum Champion
API Scripter
Guess I should build this one out a bit. :)
Thanks Aaron!  That worked like a charm!