
I was trying to create a script that runs a rollable table like a slideshow and changes side at a set interval for a set number of times. However even after the log outputs the correct token it doesn't appear to be changing the side of the rollable table itself. Any suggestions? on("chat:message", function(msg) {
if (msg.type == "api" && msg.content.startsWith("!simple-flip")) {
//example: !simple-flip -NJi3Y87o5vvrApLpR4c 1000 2
var args = msg.content.split(" ");
var tokenId = args[1];
var interval = args[2];
var repeat = args[3];
var count = 0;
setInterval(function() {
var token = getObj("graphic", tokenId);
log(token)
var currentSide = token.get("currentSide");
var newSide = (currentSide + 1) % token.get("sides").length;
token.set("currentSide", newSide);
log("interval " + interval + " repeat " + repeat)
count++;
if (count >= repeat) {
clearInterval(this);
}
}, interval);
}
});