Skip to content

Instantly share code, notes, and snippets.

@Cazra
Created February 20, 2015 03:08
Show Gist options
  • Save Cazra/b9587fd223bb88d98a2e to your computer and use it in GitHub Desktop.
Save Cazra/b9587fd223bb88d98a2e to your computer and use it in GitHub Desktop.
Roll20 Dance party
on("chat:message", function(msg) {
var cmdName = "!dance";
var msgTxt = msg.content;
// This provides a chat command to heal a character by name.
// Alternatively, you can heal all named tokens using "all" as the target.
if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) {
var danceCounter = 0;
var curPageID = findObjs({_type: "campaign"})[0].get("playerpageid");
sendChat(msg.who, "Everypony DANCE! :D");
var allCharacters = findObjs({_type: "graphic", layer: "objects", _pageid: curPageID });
var interval = setInterval(function() {
if(danceCounter < 4) {
for(var x in allCharacters) {
var character = allCharacters[x];
character.set("fliph", !character.get("fliph"));
}
}
else if(danceCounter >=4 && danceCounter < 8) {
for(var x in allCharacters) {
var character = allCharacters[x];
character.set("rotation", character.get("rotation")+90);
}
}
else {
clearInterval(interval);
}
danceCounter++;
}, 500);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment