Created
November 23, 2014 02:21
-
-
Save SteveKoontz/fabacf7aafd5c993dff7 to your computer and use it in GitHub Desktop.
Spinme API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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