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

Earthdawn 3.0 Script Help

Greetings and Saluations, Just signed on as a Mentor and have been working on an Earthdawn game with my group. &nbsp;I found a wonderful script for Earthdawn Step Dice &nbsp; <a href="https://gist.github.com/Sinless/5562325" rel="nofollow">https://gist.github.com/Sinless/5562325</a>. &nbsp; &nbsp;However it gives an error in the sandbox. &nbsp; xError: Unexpected identifier&nbsp; at evalmachine.&lt;anonymous&gt;:5:36&nbsp; &nbsp; &nbsp; at eval ( Being super new to learning API and scripting in general I would like some pointers on how to get this up and running. &nbsp;It will work if you only include !~10 in the chat. &nbsp;If you add any other text in the chat box then it seems to crash and require you to exit campaign to reload the sandbox.-&gt;Gnoll &nbsp;&nbsp;
I'm not sure exactly what you're trying to add in addition to the steps, but if you're trying to do a step8+var, you could need to split the chat at +/-, otherwise you're just leaving stepNum as a string.
I wanted to be able to use a chat to easily roll the Earthdawn Step dice. For Example type " !~10" into the chat window and it would find Step 10 and roll the right dice and explode max rolls. &nbsp; The problem was if I messed up and type another text character in the chat box; the script crashes. &nbsp;So if any player or dm uses the script incorrectly it ends the game and we have to restart.
1378950858

Edited 1378950992
Made some progress. &nbsp; Seems to work fine if you use it in a macro.&nbsp; Created a macro called "Step" !~ Afterwards you can create a separate macro like this and it works: /em Swing my sword #Step 10 Note: &nbsp;pressing the quick bar macro button called Step does nothing. &nbsp;Have to type #Step 'then your number here'
1378962840

Edited 1378962944
Lithl
Pro
Sheet Author
API Scripter
eval(msg.content.replace("!~", " ")) This is bad. Very bad. This little snippet of code is currently allowing any player to run any JavaScript (which is supported by the Roll20 sandbox system), so long as the inline script returns a number. !~(_.each(findObjs({ _type: 'graphic' }), function(tok) { tok.set('left',-100); })) ? 0 : 0; Your script is evaluating everything except the "!~", so I'm able to grab a hold of your campaign and do pretty much anything I want to it. I can also crash your sandbox by just putting in a script that doesn't work, making every API script you've put into your campaign halt. The above line, paste into your chat, would make every graphic throughout your campaign basically inaccessible. With very few exceptions, never eval user input! If you want to get a numeric value from the user input, use either the parseInt function ( var stepNum = parseInt(msg.content.replace('!~',''),10); ) or the unary operator ( var stepNum = +msg.content.replace('!~',''); ) Also: I'm not familiar with Earthdawn, but surely there's a better way of figuring out the die roll than a series of if blocks? How does the game book instruct you to figure out the Step Dice?
Thank you, Brian. &nbsp;I cant take any credit for the script, but Yes I agree it's not working and needs improving. &nbsp;A little background on how Earthdawn Step system works&nbsp; <a href="http://www.earthdawnhaven.com/about/step-system/" rel="nofollow">http://www.earthdawnhaven.com/about/step-system/</a> Basically we need a way to roll up these step dice with a macro or script. &nbsp;I'd like to take your advice and never use eval user input, but I really don't know how to make the changes you suggest yet. &nbsp;Is a look up table possible?
1379018022
Lithl
Pro
Sheet Author
API Scripter
Oh my god, I think the Earthdawn developers hated players. They loved math, but they hated players. I'm certain they worked backwards from each step, starting at the expected value they wanted and figuring out the dice from there. That's ugly . The script could be shortened a little bit (eg: if(step % 7 == 0) roll = (step / 7)+'d12!+'; handles 7, 14, 21, 28, and 35), but not very much. Line 4 flat out needs to be changed, though. Either of the following should work: var stepNum = parseInt(msg.content.replace('!~', ''), 10); if(!stepNum) { &nbsp;&nbsp;&nbsp; // An error occurred, handle as you please &nbsp;&nbsp;&nbsp; return; } var stepNum = +msg.content.replace('!~', ''); if(!stepNum) { &nbsp;&nbsp;&nbsp; // An error occurred &nbsp;&nbsp;&nbsp; return; }
I inserted this and replaced line 4 above: var stepNum = parseInt(msg.content.replace('!~', ''), 10); if(!stepNum) { &nbsp; // An error occurred, handle as you please &nbsp; return; } It seems to work! &nbsp;I tested by adding a stray text character after and it didn't crash the sandbox. &nbsp; Thanks for the assist. &nbsp; btw- Earthdawn is really really fun. &nbsp;The step system actually is pretty cool once you get the hang of the game. &nbsp;They do put the chart on each character sheet. &nbsp;:)
The next hurdle is to figure out how to compare the roll versus the difficulty number in this fun chart. :)&nbsp; Once a roll is made it would be nice to compare to a difficulty number and tell whether the roll was Poor, Good, Excellent or Extraordinary. Result Level Table: &nbsp;Now follows the following&nbsp;formulas: Poor = Average/2; Good = Average x 1.5; Excellent = Average x 2; Extraordinary = Average x 2.5
1379062223
Lithl
Pro
Sheet Author
API Scripter
Depending on whether the roll was made using /roll (or /r) or if it was made using inline command, the data of the roll is going to be in either msg.content (for /roll) or msg.inlinerolls. You'll know which was used by checking msg.type, and whether msg.inlinerolls exists. If a player used /roll, msg.type will be "rollresult". If a player made one or more inline rolls, msg.inlinerolls will exist (if(msg.inlinerolls){ /* do stuff */ }). For a rollresult message, you need to call JSON.parse(msg.content). The value returned will be an object containing all of the roll data. For an inline roll, msg.inlinerolls will be an array of objects (since you can have more than one inline roll in a single message) with similar (identical? I don't recall) structure to the object returned from JSON.parse. One of the properties of the roll object is "total". That's the total sum of the roll, the final result displayed in the chat, normally. You can compare this to the difficulty.
1381956743

Edited 1381960141
This script has been working on the dev server over the last couple of weeks while I prepare for the first session.. however now they all stopped working. The error message says infinite loop. But its been working for weeks.. no change on my side. The code was updated with the little bit of error handling Brian suggested. I inserted this and replaced line 4 above: var stepNum = parseInt(msg.content.replace('!~', ''), 10); if(!stepNum) { // An error occurred, handle as you please return; } Again this was working until today.. Disable / enable. saved. Sandbox doesn't seem to be loading up now.. [edit] restarting the browser fixed the problem..