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] Initiative Tracker Not Working, Breaking/Disabling Script

Hello all,


I have a problem I have no idea how to go about solving. I use the Pathfinder Community sheet, and host 2 weekly games. The past few days I have been discovering and utilizing scripts, with no "gamebreaking" errors I couldn't solve with trial and error. 


In short, the initiative tracker has stopped working in one game, and breaks scripts if I ever close it (after opening it). When a command is sent using                    &{tracker} it simply does not go through to chat, stoping somewhere. I have tried different variations of sending things to the tracker, and eventually came to the conclusion that it is simply broken and I have no idea why. The default initiative button won't even work now either on the sheet, as it is hard coded to send to the tracker, so I've had to work around that last game with manual macro/rolling. 


The odd thing is that in the two games I have, scripts are consistent across both, as are macros. The problem game DOES have a lot more active scripts (i.e Bump) running, but that doesn't seem like it should cause this kind of issues. The only "lead" I have right now is the error thrown back when I close the turn tracker: 

TypeError: Cannot read property 'id' of null TypeError: Cannot read property 'id' of null at turnorder.forEach.turn (apiscript.js:7200:20) at Array.forEach (native) at checkMarkerturn (apiscript.js:7199:19) at getOrCreateMarker (apiscript.js:7169:9) at removeMarker (apiscript.js:6912:9) at stopCombat (apiscript.js:6899:9) at handeIniativePageChange (apiscript.js:7560:13) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:1020:14)



I have no idea how to interpret this or what it means, as I just fiddle and modify commands presented when installing scripts, I don't actually understand coding itself. Here is a link to the scripts enabled + the error itself. Thank you for your time


July 27 (7 years ago)

Edited July 27 (7 years ago)
vÍnce
Pro
Sheet Author

You might try disabling all scripts and see if you can get initiative working again.  Then enable them one at a time to see if there may be a conflict.  Also, if the sheet init roll starts working, but your macro doesn't, post your macro.

July 27 (7 years ago)

Edited July 27 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Hi Jared, do you have a turn tracker API script installed? Something like trackerJacker or similar? The problem here is that somehow whatever initiative script you have installed is looking for a turn tracker item, but there isn't one, and then it appears that it doesn't check if there is one before going onto the next steps.

EDIT: NVM, just saw your link to what scripts are enabled.

EDIT the 2nd: Ok, so you've got combatTracker installed as your initiative tracker script. I'm not overly familiar with the script, but I gave a quick glance to it. Can you post a pic of what the turn tracker in the problem game looks like for you as GM? I think the problem here is that somehow an undefined object got added to the turn tracker array.

Edit the 3rd: Can you also put the following in as a new custom script and then post what is logged in the API console

on('ready',()=>{
    log(`turnorder string: ${Campaign().get('turnorder')}`)
    log(`turnorder as Array: ${JSON.parse(Campaign().get('turnorder'))}`);
    log(`turnorder returned from combattracker method: ${Array.from(JSON.parse(Campaign().get('turnorder'))}`);
}


July 27 (7 years ago)
The Aaron
Pro
API Scripter

I'm going to guess it doesn't handle Custom Turns and assumes every turn entry has a corresponding token.

July 27 (7 years ago)

Edited July 27 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

The Aaron said:

I'm going to guess it doesn't handle Custom Turns and assumes every turn entry has a corresponding token.

That was my first guess too, and it is true, but it's actually trying to get the id property of a null object (which of course fails), if it was just that it didn't work with custom turn items, it'd still have an object there to get the id of. I'm wondering if it isn't due to the nonstandard way that combattracker creates the turn order array (using array.from on the parsed turnorder);

July 27 (7 years ago)
The Aaron
Pro
API Scripter

Array.from(x) is identical to [...x].  Shouldn't cause any issue.

July 27 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Ah, ok

July 28 (7 years ago)

Edited July 28 (7 years ago)

Thank you so much for attempting to help me. Sorry for the very late reply-- I had some concurrent family issues arise again so I had to step away for a while. 


Got back to checking things, and disabled Combat Tracker. I don't even use it anymore, I had enabled it for testing as I was really just grasping at straws trying to get initiative to work, hoping that a API script could kick start it. Without CombatTracker enabled, there is no error that comes up when opening/closing the turn tracker. 


However, the issue does persist, with no initiative buttons/macros/shortcuts working and literally no rhyme or reason why. 


This is a .gif of the issue from my PoV. The API Output Console does not throw back any feedback at all to any of those commands. 


As for that script you posted Scott C. It is throwing back to me:


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: SyntaxError: missing ) after argument list


Which seems simple enough of a thing to solve but I tried and am uncertain of what character is extra/missing. 

Edit: Specified its initiative related commands not working.



July 28 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Ah, missed an ending parentheses in that final one, add another one before the }.

July 28 (7 years ago)

Edited July 28 (7 years ago)

I really wish I was more competent... I've added a parentheses before every } in the script, with the same result upon initialization, except for two times where I got  SyntaxError: Missing } in template expression when adding it before the } on lines 2 and 3.


July 28 (7 years ago)
vÍnce
Pro
Sheet Author

If you disable all scripts can you get init to roll from the sheet and macro?

July 28 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Sorry, Jared, this is what I get for writing code (even simple code) while on mobile. Here's the proper script:

on('ready',()=>{
    log(`turnorder string: ${Campaign().get('turnorder')}`)
    log(`turnorder as Array: ${JSON.parse(Campaign().get('turnorder'))}`);
    log(`turnorder returned from combattracker method: ${Array.from(JSON.parse(Campaign().get('turnorder')))}`);
});

So, perhaps in combination of that script, or maybe I just forgot to do this in the first place; The problem went away after I cleared items from the list on the tracker. I cannot remember if I did that prior to posting, or at any point. It seems that there was something "stuck" in the turn tracker that was completely screwing it up, that I guess went away with a list clear. Hopefully it doesn't return again. 

Thank you all for your ideas and assistance! I really appreciate you guys!

July 29 (7 years ago)
The Aaron
Pro
API Scripter

Do you know if you had a custom turn in the tracker, as added by the !act API command or by going into the turn settings and adding one?