Hi Thorrson! I'll hit your questions first, then come back for some commentary: 1) If the HP is stored in one of the token's bars, you can use TokenMod to do this, something like this for damage: !token-mod --set bar1_value|[[ {(@{target|1|bar1}-[[2d6]]),0}kh1 ]] --ids @{target|1|token_id} 2) This is a bit more complicated, certainly, you could use the above to do it, otherwise you'd likely need to write a script to handle it. Making a script is certainly an option. 3) The way I handle targeting a maximum of X targets but allowing fewer is by doubling up on the tokens selected. Lets assume you were going to put the blue status marker on up to 4 targets with token mod: !token-mod --set statusmarkers|blue --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} @{target|4|token_id} If you only wanted to put it on 2 instead, you'd just click the second one 3 times, so your command to the API might look like: !token-mod --set statusmarkers|blue --ids -JASDFAS123as12 -JQWdfawe32445 -JQWdfawe32445 -JQWdfawe32445 In TokenMod, I _.uniq() the supplied IDs, so only 2 tokens are affected. 4) You could do it! It could be as simple as you want, or as complicated as you want to make it. Here's a simplistic version: // set this up when the API is fully spun up
on('ready',function(){
"use strict";
// from the cookbook: <a href="https://wiki.roll20.net/API:Cookbook#processInlin" rel="nofollow">https://wiki.roll20.net/API:Cookbook#processInlin</a>...
var processInlinerolls = function(msg) {
if (_.has(msg, 'inlinerolls')) {
return _.chain(msg.inlinerolls)
.reduce(function(previous, current, index) {
previous['$[[' + index + ']]'] = current.results.total || 0;
return previous;
},{})
.reduce(function(previous, current, index) {
return previous.replace(index, current);
}, msg.content)
.value();
}
return msg.content;
};
// respond to chat messages
on('chat:message',function(msg){
var content,token,damage;
// make sure this is an API command and matches our !hit command
if('api' === msg.type && msg.content.match(/^!hit/) ){
// swap out inline rolls for the result, and split on spaces
content=processInlinerolls(msg).split(/\s+/);
// get the token for the supplied id
token=getObj('graphic',content[1]);
// get the damage as an integer or use 0
damage=parseInt(content[2],10)||0;
// if we found the token
if(token){
// set it's bar1 to the current value - the damage
token.set('bar1_value',(parseInt(token.get('bar1_value'),10)||0)-damage);
// send a message to chat with the details
sendChat('','Token: '+token.get('name')+' took '+damage+' damage.');
}
}
});
});
You might call it like this: !hit @{target|token_id} [[2d6]] I'd say, get that working (I didn't test it...) and see if you understand what it's doing (don't worry so much about processInlinerolls), then see about expanding it. The API is written in JavaSCRIPT, btw, so if you go digging, look for Javascript, not Java. (The history of why the two names are similar is not important, we're just left with the legacy of annoyance from the decision. =D) Also, be sure to ask any questions you have. You can post them in the forum or feel free to PM me if you'd rather for any reason. We're all happy to help!