I was given this a while back by an arcane scriptomancer. It removes a token from the turn order if bar1 goes to -1 or lower. You can change that threshold if need be. I use it to remove NPCs that fall in battle, and I set PC health to 0 when they fall, so they stay in the turn order for Death Saves. Hope this helps! on('ready',function() {
'use strict';
// Threshold to be equal to or less than to get removed
var threshold = -1;
// 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));
}
});
});