Victor B. said: Yes, log every step in your process. Pull down CFX code and add logs to that. Display input command, every variable that's getting set or used in an IF statement, whether you are correctly getting into an IF, etc..This is how I unwound the Roll20AM process. For example if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) isn't api capitalized? API. For whatever reason lower case api works. I did what you and TheAaron suggested. I created checkpoints after every variable being set or function being ran and output everything to the log. The reason I couldn't get !cfx to work was because it was using msg.playerid which when an API script runs a second script through sendChat it gives a msg.playerid of "API". I did the following: function delayFunction(speaker, output, pid) {
return function() {
if (output.indexOf("!") !== -1)
sendChat("player|" + pid, output.trim());
else
sendChat(speaker.trim(), output.trim());
}
} As specified here in the chat API docs to pass a playerid with sendChat But when I get the msg.playerid on the command the API ran it gives back 2 playerid's "-L8dGoF0vNWip8COLBX6"
"API" I haven't programmed anything in about 3 years+ until I started using Roll20 so I'm a little rusty and I can't remember how to get the first playerid from the 2 strings. Even so if I did it that way I would have to edit each script that uses msg.playerid so it works with delays. The Aaron said: I suggest having your script log what the command is, then copy/paste that into the chat and verify it works. I did this with CFX and all my problems revolved around msg.playerid. I changed this: const getPageForPlayer = (playerid) => {
let player = getObj('player',playerid);
if(playerIsGM(playerid)){
return player.get('lastpage');
}
let psp = Campaign().get('playerspecificpages');
if(psp[playerid]){
return psp[playerid];
}
return Campaign.get('playerpageid');
}; To this: let pageid = Campaign().get("playerpageid"); And that fixed my issues with CFX and it now works with !delay. Right now I'm trying to get it to work with !token-mod Here is the output from !delay, the playerid and command sent to sendChat: "PID: -L8dGoF0vNWip8COLBX6 Command: !token-mod --set layer|gmlayer --ids -LBOyktq-VWzBplvzTU7" I can paste the following directly into the chat and it works: !token-mod --set layer|gmlayer --ids -LBOyktq-VWzBplvzTU7 But it won't run from the !delay command. I went into token-mod and on line 2328 at the start of handleInput I added: log("PID: " + msg.playerid); And it outputs this when running the "!token-mod --help" command wrapped in the !delay command "PID: -L8dGoF0vNWip8COLBX6"
"PID: API"
{"who":"error","type":"error","content":"Unable to find a player or character with name: API"} How do I get it to use the first PID or remove the second "API" PID? Is there any workaround for this that doesn't involve editing every single script that uses msg.playerid?