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

Are there chatline commands to modify the bar stats on tokens?

I use two tokens to measure a GM & Player resource pool. I've spent the past hour and a half scouring the documentation and forums trying to find a solution that doesn't involve API scripts with no results. Are there commands that can be typed into the chatline that will directly modify the "Bar" values of a token? I am trying to write a macro that will subtract 1 from the GM's resource token's Bar1 and subsequently add 1 to the Players' resource token's Bar1.
1382607493
Gauss
Forum Champion
At this time information can be pulled from bars and attributes but information cannot be sent to them via a macro. Sorry. - Gauss
1382660647
Lithl
Pro
Sheet Author
API Scripter
Not with the vanilla VTT. You can create a script to accomplish it, though. on('chat:message', function(msg) { if (msg.type != 'api') return; var parts = msg.content.split(); var command = parts.shift().substring(1); var amount = parts.length > 0 ? +parts[0] : 0; _.each(msg.selected, function(obj) { var tok = getObj('graphic', obj._id); if (!tok || tok.get('subtype') != 'token') return; var message = tok.get('name') + '\'s {0} was {1}; added {2}, and {0} is now {3}'; var arg1, arg3; switch (command) { case 'bar1': message.replace('{0}', 'bar1'); var bar1_cur = arg1 = +tok.get('bar1_value'); var b1hs_max = tok.get('bar1_max') != ''; var bar1_max = +tok.get('bar1_max'); var bar1_nxt = bar1_cur + amount; if (b1hs_max && bar1_nxt > bar1_max) bar1_nxt = bar1_max; arg3 = bar1_nxt; tok.set('bar1_value', bar1_nxt); break; case 'bar2': message.replace('{0}', 'bar2'); var bar2_cur = arg1 = +tok.get('bar2_value'); var b2hs_max = tok.get('bar2_max') != ''; var bar2_max = +tok.get('bar2_max'); var bar2_nxt = bar2_cur + amount; if (b2hs_max && bar2_nxt > bar2_max) bar2_nxt = bar2_max; arg3 = bar2_nxt; tok.set('bar2_value', bar2_nxt); break; case 'bar3': message.replace('{0}', 'bar3'); var bar3_cur = arg1 = +tok.get('bar3_value'); var b3hs_max = tok.get('bar3_max') != ''; var bar3_max = +tok.get('bar3_max'); var bar3_nxt = bar3_cur + amount; if (b3hs_max && bar3_nxt > bar3_max) bar3_nxt = bar3_max; arg3 = bar3_nxt; tok.set('bar3_value', bar3_nxt); break; default: return; } message.replace('{1}', arg1); message.replace('{2}', amount); message.replace('{3}', arg3); sendChat('SYSTEM', '/w ' + msg.who.split(' ')[0] + ' ' + message); }); }); The above should give you three new commands: !bar1 number , !bar2 number , and !bar3 number , where number is some value (the above script will not work with math, only number literals). The number will be added to the current value of the bar of all selected tokens. If the bar has a maximum, the bar will be capped at that maximum (no overflowing the bar). The above does not prevent the bar from being underflowed (letting you go negative), but that's a simple change if you also want to prevent that. You'll be sent a whisper by the system notifying you that the script worked. Note: I haven't tested this script. Provided as-is. =)