I'm just starting my adventure into JavaScript just for the API. I have no coding background and I'm not even sure what's possible to do with this. So far, I have done just enough Code Academy and learning by example to splice together pieces of scripts to get a token to move in one direction when triggered by a chat event with a variable to select which token moves. You might recognize parts of this as something of yours- once beautiful, now tortured and defiled to suit my purposes.
on("chat:message", function(msg) {What I need next is to figure out how to add the variable token from the journal page to a specific location on the table, add a pause, and then run what I already have. Later on, I'll need to figure out how to delete the token from the table.
if(msg.type == "api" && msg.content.indexOf("!entr ") !== -1) {
var charName = msg.content.replace("!entr ", "");
var patroltoken = findObjs({_type: "graphic", name: charName})[0];
sendChat(msg.type = " ", "/em" + " " + charName + " " + "enters the arena.");
if(!patroltoken) {
return;
}
var direction = 70;
var stepstaken = 0;
setInterval(function() {
if(stepstaken === 10) {
return;
}
patroltoken.set("top", patroltoken.get("top") + direction);
stepstaken++;
}, 1500);
}});
I tried jamming a getObj helper function in there to see if it would work, but I'm not sure if that's what I need to do. I'm not asking for written code, just where to look next. Once I have this knowledge under my belt, I think I'll be able to finish my entrance animations without many problems and I can go back to being as terrible at everything else as I am at this.
Thanks,
Melvin McSnatch