I've not tested this yet, but this should do what you want. !bar-status <bar number> <status name> <value to compare to> <comparison type> <reset status on failed comparison> --ids <token id> [<token id> ...] Possible comparisons (case insensitive): LessThan GreaterThan LessThanOrEqual GreaterThanOrEqual Equal Example: !bar-status 2 back-pain 1 LessThan yes --ids @{target|token_id} Reasonable defaults are chosen for omitted options: !bar-status --ids @{target|token_id} @{selected|token_id} -JAdfasJas12ss5 Will check bar 1 is greater than 0 and set back-pain if that's the case but not reset. Let me know how it goes, I'll try and test this a bit later tonight... Code: on('ready',function(){
"use strict";
var compFuncs={
greaterthan: (o,v) => parseInt(o,10)>v,
lessthan: (o,v) => parseInt(o,10)<v,
greaterthanorequal: (o,v) => parseInt(o,10)>=v,
lessthanorequal: (o,v) => parseInt(o,10)<=v,
equal: (o,v) => parseInt(o,10)===v
},
yesValues = [1,'1','on','yes','true','sure','yup','-'],
statusValues = ['red', 'blue', 'green', 'brown', 'purple', 'pink',
'yellow', 'dead', 'skull', 'sleepy', 'half-heart', 'half-haze',
'interdiction', 'snail', 'lightning-helix', 'spanner', 'chained-heart',
'chemical-bolt', 'death-zone', 'drink-me', 'edge-crack', 'ninja-mask',
'stopwatch', 'fishing-net', 'overdrive', 'strong', 'fist', 'padlock',
'three-leaves', 'fluffy-wing', 'pummeled', 'tread', 'arrowed', 'aura',
'back-pain', 'black-flag', 'bleeding-eye', 'bolt-shield', 'broken-heart',
'cobweb', 'broken-shield', 'flying-flag', 'radioactive', 'trophy',
'broken-skull', 'frozen-orb', 'rolling-bomb', 'white-tower', 'grab',
'screaming', 'grenade', 'sentry-gun', 'all-for-one', 'angel-outfit',
'archery-target'],
toBar = (o) => {
let v=parseInt(o,10);
return `bar${ _.contains([1,2,3],v) ? v : 1}_value`;
},
toStatus = (o) => {
return _.contains(statusValues,o) ? o : 'back-pain';
},
toValue = (o) => {
return parseInt(o,10) || 0;
},
toCompFunc = (o) => {
let v=o.toLowerCase();
return (_.has(compFuncs,v) ? compFuncs[v] : compFuncs.greaterthan );
},
toReset = (o) => {
return _.contains(yesValues,o);
};
on('chat:message',function(msg_orig){
var cmd,bar,status,comparison,value,ids,msg,tokens,reset;
if('api' !== msg_orig.type || !playerIsGM(msg_orig.playerid) ){
return;
}
msg=_.clone(msg_orig);
if(_.has(msg,'inlinerolls')){
msg.content = _.chain(msg.inlinerolls)
.reduce(function(m,v,k){
var ti=_.reduce(v.results.rolls,function(m2,v2){
if(_.has(v2,'table')){
m2.push(_.reduce(v2.results,function(m3,v3){
m3.push(v3.tableItem.name);
return m3;
},[]).join(', '));
}
return m2;
},[]).join(', ');
m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;
return m;
},{})
.reduce(function(m,v,k){
return m.replace(k,v);
},msg.content)
.value();
}
ids = msg.content.split(/\s+--ids\s+/);
cmd = ids.shift().split(/\s+/);
ids=( ( ids[0] && ids[0].split(/\s+/) ) || []);
ids = _.union(ids, ((msg.selected && _.pluck(msg.selected,'_id')) || []) );
switch(cmd.shift()){
case '!bar-status':
bar = toBar(cmd.shift());
status = toStatus(cmd.shift());
value = toValue(cmd.shift());
comparison = toCompFunc(cmd.shift());
reset = toReset(cmd.shift());
tokens = _.chain(ids)
.uniq()
.map( (id) => getObj('graphic',id) )
.reject(_.isUndefined)
.each( o => {
if( comparison(o.get(bar),value)){
o.set(`status_${status}`,true);
} else if(reset){
o.set(`status_${status}`,false);
}
});
}
});
});