Skip to content

Instantly share code, notes, and snippets.

@SteveKoontz
Created November 23, 2014 02:21
Show Gist options
  • Save SteveKoontz/fabacf7aafd5c993dff7 to your computer and use it in GitHub Desktop.
Save SteveKoontz/fabacf7aafd5c993dff7 to your computer and use it in GitHub Desktop.
Spinme API
var spinme = function(otoken) {
otoken.set({rotation: otoken.get("rotation")+10});
if(otoken.get("rotation") === 360){
otoken.set({rotation: 0});
};
log(otoken.get("rotation"));
}
on('chat:message', function(msg) {
if(!(msg.selected && msg.selected.length > 0)) return; // Make sure there's a selected object
var token = getObj('graphic', msg.selected[0]._id);
if(token.get('subtype') != 'token') return; // Don't try to spin a drawing or card
var spinthis = function() {
spinme(token);
}
if(msg.type == 'api' && msg.content.indexOf('!spin') !== -1)
{
intervalId = setInterval(spinthis, 200);
}
else if(msg.type == 'api' && msg.content.indexOf('!stop') !== -1)
{
clearInterval(intervalId);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment