Skip to content

Instantly share code, notes, and snippets.

@SteveKoontz
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveKoontz/ecdd84868bd8efb4f568 to your computer and use it in GitHub Desktop.
Save SteveKoontz/ecdd84868bd8efb4f568 to your computer and use it in GitHub Desktop.
on('chat:message', function(msg) {
if(msg.type != 'api') return;
var parts = msg.content.toLowerCase().split(' ');
var command = parts.shift().substring(1);
var selected = msg.selected;
if(command != 'blue' || !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_blue', 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 += 'blue@'+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);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment