Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

help

hey guys,

I tried to use API scrips and they worked for a little bit then after a few minutes they stopped working and started giving me errors with no modifications to them can ya help

example
"turn order highlighter"
"Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again.More info...

For reference, the error message generated was: evalmachine.<anonymous>:35 last_token.set({ ^ TypeError: Cannot call method 'set' of undefined at null.<anonymous> (evalmachine.<anonymous>:35:29) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
evalmachine.<anonymous>:151
last_token.set({
^
TypeError: Cannot call method 'set' of undefined
at null.<anonymous> (evalmachine.<anonymous>:151:29)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Restarting sandbox due to script changes...
Spinning up new sandbox...
evalmachine.<anonymous>:35
last_token.set({
^
TypeError: Cannot call method 'set' of undefined
at null.<anonymous> (evalmachine.<anonymous>:35:29)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Restarting sandbox due to script changes...
Spinning up new sandbox...
Restarting sandbox due to script changes...
Spinning up new sandbox...
Restarting sandbox due to script changes...
Spinning up new sandbox...
Error downloading scripts (probably no scripts exist for campaign.)
Spinning up new sandbox...
Error downloading scripts (probably no scripts exist for campaign.)
Restarting sandbox due to script changes...
Spinning up new sandbox...
evalmachine.<anonymous>:35
last_token.set({
^
TypeError: Cannot call method 'set' of undefined
at null.<anonymous> (evalmachine.<anonymous>:35:29)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Restarting sandbox due to script changes...
Spinning up new sandbox...
Error downloading scripts (probably no scripts exist for campaign.)
Restarting sandbox due to script changes...
Spinning up new sandbox...
evalmachine.<anonymous>:35
last_token.set({
^
TypeError: Cannot call method 'set' of undefined
at null.<anonymous> (evalmachine.<anonymous>:35:29)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)




February 12 (10 years ago)
Gid
Roll20 Team
I'm going to move this in the API forum. Should get more eyes to see this.
ok ty i was going to but i didnt know if bug reports went there
February 12 (10 years ago)
It's hard to tell exactly without seeing the code. I ran into this message myself earlier today and it was because I thought I was accessing a certain type of object, and the actual type that I got was different and didn't contain the set() method, or last_token doesn't have a valid value. It's pure guessing without code however.

"[Script] Auto Initiative"


var Combat_Begins = Combat_Begins || {};
Combat_Begins.statName = new Array ("Dex"); //Stats to be added to roll, commas between values
Combat_Begins.rollValue = 20; //rolling 1d20, change if you roll 1dXX
Combat_Begins.sendChat = true; //True if you want the chat log to show their results
Combat_Begins.includeChars = true; //set false if you want to roll for players
//If you want players to roll, make this a global macro (add other stats as needed):
// @{selected|token_name} rolls a [[ 1d20 + @{selected|Dex} &{tracker} ]] for initiative!
on("chat:message", function(msg) {
if (msg.type == "api" && msg.content.indexOf("!CombatBegins") !== -1 && msg.who.indexOf("(GM)") !== -1) {
Campaign().set("initiativepage", false );
if (Combat_Begins.sendChat == true) {
sendChat("", "/desc Combat Begins!");
}
try{
_.each(msg.selected, function(selected) {
var obj = getObj("graphic", selected._id);
//Test for players, exit if players roll themself
var currChar = getObj("character", obj.get("represents")) || "";
var initString = "";
var TokenName = "";
var CharName = "";
if (currChar.length != 0) {
CharName = currChar.get("name");
if (currChar.get("controlledby") != "" && Combat_Begins.includeChars == false ) return;
if (CharName != "") {
_.each(Combat_Begins.statName, function(stat) {
//cycle through each stat and add it to mod
var mod = findObjs({
name: stat,
_characterid: obj.get("represents"),
}, {caseInsensitive: true});
if ( mod.length != 0 ) { initString = initString + " + " + mod[0].get("current"); }
});
}
var pre = "";
if (Combat_Begins.sendChat == false || currChar.get("controlledby") == "") {
pre = "/w GM ";
};
var string = "I rolled a [[1d" + Combat_Begins.rollValue + initString + "]] for initiative!";
var result = 0;
sendChat("character|" + obj.get("represents"), string, function(ops) {
var rollresult = ops[0];
result = rollresult.inlinerolls[1].results.total;
var turnorder;
if(Campaign().get("turnorder") == "") {
turnorder = [];
} else turnorder = JSON.parse(Campaign().get("turnorder"));
turnorder.push({
id: selected._id,
pr: result,
});
turnorder.sort(function(a,b) {
first = a.pr;
second = b.pr;
return second - first;
});
Campaign().set("turnorder", JSON.stringify(turnorder));
sendChat("character|" + obj.get("represents"), pre + "I rolled a " + result + " for initiative!");
});
} else {
//handles non-linked tokens. Rolls the die value and uses it.
sendChat(obj.get("name"), "I rolled a [[1d" + Combat_Begins.rollValue + "]] for initiative!", function(ops) {
var rollresult = ops[0];
result = rollresult.inlinerolls[1].results.total;
var turnorder;
if(Campaign().get("turnorder") == "") {
turnorder = [];
} else turnorder = JSON.parse(Campaign().get("turnorder"));
turnorder.push({
id: selected._id,
pr: result,
});
turnorder.sort(function(a,b) {
first = a.pr;
second = b.pr;
return second - first;
});
Campaign().set("turnorder", JSON.stringify(turnorder));
sendChat(obj.get("name"), "/w GM I rolled a " + result + " for initiative!");
});
}
});
} catch(err){return;}
Campaign().set("initiativepage", true );
}
if (msg.type == "api" && msg.content.indexOf("!CombatEnds") !== -1) {
Campaign().set("turnorder", "");
Campaign().set("initiativepage", false );
if (MovementTracker.MovementTracker == true) { ResetAllPins() };
};
});

but im getting the errors for all scripts dont know if its the exact same error but im getting them im trying to use "auto ini, torch timer,turn order high lighter and circle/cone template v2
February 13 (10 years ago)
Fabio M.
KS Backer
Sometimes a script needs a specific object in the page. For example, the code that you pasted above requires the graphic object named XPin - called from the function ResetAllPins() - to be present. I don't know whether this function checks for the existence of such object before trying to do something with it, but if it doesn't, that could the culprit.
Just shooting in the dark here, though.
well i have no idea cause they worked then they didnt i did add or change anything cause i dont even know how lol
February 13 (10 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Do you have the Gist link where you got it?

Best thing is to try to comment out the code and open it up to run section by section.
im not a programmer i dont know what im doing
February 13 (10 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
https://gist.github.com/DarokinB/5826648

I think its Josh's.....

With no tokens or anything it seemed to run for me (no errors and the turn tracker came up.)

I would create a new clean campaign and just see if it works for you in that campaign.

Just for starters.
nope still error
February 15 (10 years ago)

Edited February 15 (10 years ago)
Fabio M.
KS Backer
Which turn order highlighter are you using. If it's HoneyBadger's, are you sure you have the graphic token in your page, as per his instructions? (Initiative highlighter).
It should check for the token and exit if it's not found, but just in case...

Anyway, disable all the scripts in your campaign but one, and try it. Proceed like this for all your scripts, testing one at a time. At least you can pinpoint the one not working. And mind that some scripts are incompatible with each other, meaning that taken on their own they are good, but together with specific others they could give you errors.