Created
January 11, 2018 15:56
-
-
Save anonymous/cb41dde6c83fa8c57b005904b2fd799a to your computer and use it in GitHub Desktop.
This file contains 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
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