Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2018 15:56
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 anonymous/cb41dde6c83fa8c57b005904b2fd799a to your computer and use it in GitHub Desktop.
Save anonymous/cb41dde6c83fa8c57b005904b2fd799a to your computer and use it in GitHub Desktop.
on("ready", function() {
//Wait until the ready event fires so we know the campaign is completely loaded.
//Get a reference to our patrolling token.
log("Going Deadhands...");
var patroltoken = findObjs({_type: "graphic", name: "Deadhands"})[0]; //We know there is a token in the Campaign called "Deadhands".
if(!patroltoken) {
log("Deadhands");
return;
}
var direction = -70; //Walk left 70 pixels.
var stepstaken = 0; //How many steps have we walked in the current direction?
setInterval(function() {
if(patroltoken.get("status_redmarker") === false) return;
if(stepstaken > 2) {
//Switch directions!
direction = direction * -1; //will "flip" the direction we're walking
stepstaken = 0; //reset steps back to 0.
patroltoken.set({
fliph: true
});
}
patroltoken.set("left", patroltoken.get("left") + direction); //walk!
stepstaken++;
}, 3000); //take an action every 3000 = 5 seconds
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment