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

Help with Status Marker API on Cards

1424278158

Edited 1424278424
My game uses an injury system where injuries can be gained by taking certain amounts of damage. Each character has an Injuries attribute with a max of 10, and I've implemented this script so that injuries can be added with just the click of a button. It's just a quick rehash of a Blue Status Marker code with some inline roll help from one of The Aaron's scripts, so forgive the sloppiness, as I'm a noob. (I run it alongside this script to keep the attribute consistent with the Status Marker, but that probably won't be relevant to this problem.) on('chat:message', function(msg_orig) { if(msg_orig.type != 'api') return; // TheAaron's Inline Roll Expansion Code var msg = _.clone(msg_orig); if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']=v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } var parts = msg.content.toLowerCase().split(' '); var command = parts.shift().substring(1); var selected = msg.selected; if(command != 'injury' || !selected) return; // use the !blue command, and have one or more things selected var count = +parts[0]; if(!count) count = 0; // if no height is returned, treat as 0 _.each(selected, function(obj) { if(obj._type != 'graphic') return; // only blue graphics var tok = getObj('graphic', obj._id); if(tok.get('subtype') != 'token') return; // don't try to blue cards tok.set('status_half-heart', false); var addblue = ''; while(count > 0) { // get current digit, starting from ones var digit = count / 10; digit -= Math.floor(digit); digit = Math.round(digit * 10); // shift height count = Math.floor(count / 10); addblue += 'half-heart@'+digit+','; } if(addblue.length > 0) addblue = addblue.substring(0, addblue.length - 1); // trim trailing comma var markers = tok.get('statusmarkers'); if(markers != '') markers += ','; markers += addblue; tok.set('statusmarkers', markers); }); }); I call this script with a macro bar button that performs the following: !injury [[@{selected|Injuries} +?{Injuries Gained|1}]] The Good News: This works perfectly on all standard tokens. I'm very satisfied with the way it works. The Bad News: "Summoning" is the most central feature of my game. All summoned creatures are handled with cards for ease of use with players. Summoned creatures can gain injuries just like everything else. Except that this script doesn't work on cards that are linked to characters for some reason. Halp?
1424278995
The Aaron
Pro
API Scripter
The subtype for cards is 'card': if(tok.get('subtype') != 'token') return; // don't try to blue cards You could change this to: if( tok.get('subtype') === 'card' && tok.get('isdrawing') ) { return; // don't try to blue cards that are drawings } Basically, you can't (or at least it won't work right) set statusmakers on a drawing. I'm pretty certain you are playing cards as tokens, so they will have isdrawing false and slip through, where as playing cards you happen to lay on the table will be drawings.
So will i just have to add the markers manually, or is there a way to make a script that determines whether or not it's a card and marks it appropriately? My cards are tokens, if that helps.
1424283740
The Aaron
Pro
API Scripter
Just replace the code in my first block above with the code in my second block above and it should work. =D
Wow, it worked! Thank you!
1424288498
The Aaron
Pro
API Scripter
no problem! =D