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

The One Ring APIs sortTurnorder Not Defined.

Hello, I'm trying to set up a One Ring campaign as per this page, and when I setup the tor-stance and tor-stance-to-turnorder .js files, it gives me the error that sortTurnorder is not defined and crashes the API. I'm not sure if my characters are missing attributes, I did something wrong, or something changed in Roll20 and the scripts are just out of date. Is anyone still using them?
1492039244
Lithl
Pro
Sheet Author
API Scripter
I'm not familiar with the script in question, but it sounds like you're missing some part of it. Can you give a link?
Here are the setup instructions. He has you start setting up those scripts under Battle Map Setup. I could invite you into the campaign too, but I don't know if you can see the API page.
1492042417
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Just a note, you haven't actually been linking anything.
1492049354
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Scott C. said: Just a note, you haven't actually been linking anything. The link button on the forums isn't very intuitive. There an extra step that is easy to miss. I made that mistake a lot at first.
<a href="http://ringen.squarespace.com/loremasters-journal/2014/10/26/the-one-ring-setup-for-roll-20" rel="nofollow">http://ringen.squarespace.com/loremasters-journal/2014/10/26/the-one-ring-setup-for-roll-20</a>
Okay, that one worked. I was pretty fried when I made that last post. I probably just posted too late in the work day. To reiterated: He has you start setting up those scripts under Battle Map Setup. Scroll down to that section.
1492124503
Lithl
Pro
Sheet Author
API Scripter
I don't see any reason why&nbsp;setStanceOnTokensCharacter would fail to see&nbsp;sortTurnorder. Are you certain you saved&nbsp;tor-stance-to-turnorder.js on your scripts page?
Yeah, and I've recopied the both scripts in to make sure I had them all. I also deleted and remade them just in case something weird was happening. I'm only testing with one character. It should work with one character, right? Here's the complete error: 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: Unexpected end of JSON input SyntaxError: Unexpected end of JSON input &nbsp; &nbsp; &nbsp;at JSON.parse (&lt;anonymous&gt;) &nbsp; &nbsp; &nbsp;at sortTurnorder (apiscript.js:98:26) &nbsp; &nbsp; &nbsp;at setStanceOnTokensCharacter (apiscript.js:84:5) &nbsp; &nbsp; &nbsp;at updateStanceOnDrop (apiscript.js:58:9) &nbsp; &nbsp; &nbsp;at apiscript.js:31:5 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) &nbsp; &nbsp; &nbsp;at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) &nbsp; &nbsp; &nbsp;at TrackedObj.set (/home/node/d20-api-server/api.js:901:14) &nbsp; &nbsp; &nbsp;at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) &nbsp; &nbsp; &nbsp;at /home/node/d20-api-server/api.js:1378:11
1492184769

Edited 1492184808
Lithl
Pro
Sheet Author
API Scripter
Okay, that's very different from the error in the thread title. Looks like the script is trying to sort the turn order without having anything in it yet. Change line 13 of tor-stance-turnorder.js from: var turnorder = JSON.parse(campaign.get('turnorder')); To: var turnorder; if (campaign.get('turnorder') == '') turnorder = []; else turnorder = JSON.parse(campaign.get('turnorder'));
Thank you! First of all, looks like the message change when I completely deleted the scripts and readded them and I just didn't notice, and second, I didn't realize from his instructions that you need to add the turns manually first. So now it's working. Thank you!!!
1492610905

Edited 1492622177
Robert D. You just saved me a lot of time. I went Pro on roll20 only so I could play with Heilemann TOR scripts, but I got kinda upset when I couldn't get this to work, so I was just about to post on this thread when I saw your post. But tell me, how did you fix it? I can't get it to work. What did you mean by "you need to add the turns manually first"? Did you have to create any kind of attribute for each character? If so, what should I call it? And did you have to make the change suggested by Mr. Brian up there? Thank you all for your help here, guys. ------------------------------------------------------- Edit: Nevermind, guys, I figured it out, thank you from the bottom of my heart. Mr. Brian, you saved the day, sir! And Robert, right after I got it to run I wasn't sure why it wasn't showing anything, but then I remembered your post and understood what you meant. You guys helped me a lot!
1492624441

Edited 1492624616
Now, on a related matter. Robert, have you managed to get tor-state-checker.js and tor-mook-state-checker.js to run? These are the only ones I still couldn't get to work. I keep getting the following error log: 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: TypeError: weary.set is not a function TypeError: weary.set is not a function at checkWeary (apiscript.js:145:19) at Array.forEach (native) at apiscript.js:117:16 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) at checkForReady (/home/node/d20-api-server/api.js:1314:12) at /home/node/d20-api-server/api.js:1394:9 at c (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:14:64) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) Do you guys have any clue about what to do here?
I don't think I've set those up, because the weary rolling is working for me, and the GM isn't actually using the Roll20. Do the characters have the weary field?
Yes, they do have the weary field. The weary rolling by rollable tables and macros are working for me too, but without those scripts I have to keep an eye on fatigue (both from travel and from battle), and then I have to change the weary attribute manually every time a character gets endurence points bellow encumbrance fatigue. Because if I forget to change it manually, the rolls will be done as if characters were never weary. So those scripts can help a lot!
Yeah, I went and added those tokens and scripts. Not sure what they do, but they aren't throwing errors. I started getting errors on the turn order again, though, and it was caused by the stance field not existing on the attributes, so I suspect any errors you get are from them not having the right fields. Weary, probably.
So, about tor-state-checker.js (the more important one), I double checked and every single one of my characters has weary as an attribute, but even with no characters tokens the script instantly crashes the second I hit "save script", with the same error message. So I don't know what to do next. About the tor-mook-state-checker.js , it's not causing any crash, but it does not change the weary stats of my mook tokens either. I tried it all, linking weary to bar 3, not linking, changing the attribute to normal/weary... Not sure how to get this thing to work either, but at least it's not crashing anything.
1492633843
Lithl
Pro
Sheet Author
API Scripter
to-state-checker.js is using getAttrByName to set the value of weary, and then attempting to update the value of the weary attribute from the weary variable. However, getAttrByName only returns the value &nbsp;of the attribute, not the attribute itself. You should be able to replace: var weary = getAttrByName(characterid, 'weary', 'current'); With: var weary = findObjs({type: 'attribute', characterid: characterid, name: 'weary'})[0]; I don't think any of the other attributes there need to be changed.
Thank you, Brian! I knew you were the right man for the task. Thank you too, Robert, as I said before you saved me a lot of time. I finally got everything to work just fine. The problem with tor-mook-state-checker.js by the way was kind of silly, if anyone reading this thread from the future would like to know... It was: if (hate === '0') { See? 3 " = ", I changed it to : if (hate == '0') { and it worked just fine.
1492666729
Lithl
Pro
Sheet Author
API Scripter
João Vitor M. said: The problem with tor-mook-state-checker.js by the way was kind of silly, if anyone reading this thread from the future would like to know... It was: if (hate === '0') { See? 3 " = ", I changed it to : if (hate == '0') { and it worked just fine. From a coding style standpoint, it would be better to use parseInt(hate) === 0 rather than hate == '0' . The strict equality operator (===) checks if the two operands are exactly the same, while the abstract equality operator (==) checks if they're same-ish, with a set or rules for what counts as "same" that it at times absolutely bizarre and generally not worth remembering. For example: '' == false // -&gt; true null == undefined // -&gt; true [] == false // -&gt; true And yet, despite that last one, if ([]) &nbsp;treats the empty array as being a truthy value.
1492697605
The Aaron
Pro
API Scripter
Brian said: And yet, despite that last one, if ([]) &nbsp;treats the empty array as being a truthy value. I imagine it's because if([]) treats [] as ''.