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

Custom Sheet - Sheet Worker and Syntax Error Problems

After working on this sheet for about a month now I'm fairly confident with html and css (thank god for w3schools) Anyway, I've got two (presumably unrelated) problems. Firstly, I have a sheet worker that does no work and I can't tell why. From what I've read on the wiki and checking what others have done here on the forums, it doesn't seem wrong, though JS is definitely not something I know nearly at all. <script type='text/worker'> on("change:resolve change:fortitude change:endurance", function() { getAttrs(["resolve,fortitude,endurance"], function(v) { let resolve = parseInt(v.resolve,10)||0; let fortitude = parseInt(v.fortitude,10)||0; let endurance = parseInt(v.endurance,10)||0; let hp = 3 + fortitude + endurance; let nerve: 2 + fortitude + resolve; setAttrs({ hp: hpmax, nerve: nervemax }); }); }); </script> It would probably be a lot easier to just write an autocalc formula for it, but I just wanted to go the route of avoiding them altogether as I build the character sheet. The other problem I'm having is a syntax error. SyntaxError    column :   4 expected :  (8)  [ "","" ,  ""."" ,  ""["" ,  ""e"" ,  ""}"" ,  "[ |\t]" ,  "[+|\-|*|\/|%]" ,  "[0-9]" ] found :  " d " line :  1 message :  " Expected ",", ".", "[", "e", "}", [ |\t], [+|\-|*|\/|%] or [0-9] but "d" found. " name :  " SyntaxError " offset :  3 __proto__ :  Object I only get it when I try to roll with a negative dice pool. The way I have the roll template set up, I have 3 different rolls that will be made depending on if the dice pool is above, equal to, or below 0. Dice pools of above 0 and 0 roll just fine and display properly. But the negative dice pool roll, which is just {{belowzero=[[0]]}} doesn't work at all and I can't tell why. I'm assuming "found: d" doesn't really mean I have a "d" where I shouldn't because I really just can't find one misplaced. Here's the roll: <button type='roll' class='skillbutton' value='&{template:railer} {{name=@{charname}}} {{rollname=an Athletics Check}} {{attr=Athletics}} {{attrnum=@{athletics}}} {{mod=?{Modifier|0}}} {{tn=?{Target Number|4}}} {{poolsize=[[@{athletics}+?{Modifier|0}]]}} {{abovezero=[[{[[@{athletics}+?{Modifier|0}]]d8!}>?{Target Number|4}f1]]}} {{zero=[[{{d8!}>?{Target Number|4}f1,{d8!}>?{Target Number|4}f1}kl1]]}} {{belowzero=[[0]]}}'> And here's the important part of the roll template: <div class='row'> <div class='result'> {{#rollGreater() poolsize 0}} {{abovezero}} Hits: {{/rollGreater() poolsize 0}} {{#rollTotal() poolsize 0}} {{zero}} Hits: {{/rollTotal() poolsize 0}} {{#rollLess() poolsize 0}}  {{belowzero}} Hits: {{/rollLess() poolsize 0}} </div> <div class='resulttype'> {{#rollGreater() poolsize 0}} <span class='success'> {{#rollGreater() abovezero 4}} Great Success! {{/rollGreater() abovezero 4}} {{#rollBetween() abovezero 3 4}} Success! {{/rollBetween() abovezero 3 4}} {{#rollBetween() abovezero 1 2}} Complicated Success! {{/rollBetween() abovezero 1 2}} </span> <span class='failure'> {{#rollTotal() abovezero 0}} Failure! {{/rollTotal() abovezero 0}} {{#rollLess() abovezero 0}} Complicated Failure! {{/rollLess() abovezero 0}} </span> {{/rollGreater() poolsize 0}} {{#rollTotal() poolsize 0}}  <span class='success'> {{#rollGreater() zero 4}} Great Success! {{/rollGreater() zero 4}} {{#rollBetween() zero 3 4}} Success! {{/rollBetween() zero 3 4}} {{#rollBetween() zero 1 2}} Complicated Success! {{/rollBetween() zero 1 2}} </span> <span class='failure'> {{#rollTotal() zero 0}} Failure! {{/rollTotal() zero 0}} {{#rollLess() zero 0}} Complicated Failure! {{/rollLess() zero 0}} </span> {{/rollTotal() poolsize 0}} {{#rollLess() poolsize 0}}  <span class='failure'>Automatic Failure!</span> {{/rollLess() poolsize 0}} </div> </div> Any insight would be appreciated. I've been working on both of these the last few days and am just stumped.
1555551363
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Just a quick note on your first question, but your getAttrs is incorrect. You need a separate string for each attribute name in the array instead of doing "resolve,fortitude,endurance" it should be "resolve","fortitude","endurance": <script type='text/worker'> on("change:resolve change:fortitude change:endurance", function() { getAttrs(["resolve " ,"fortitude","endurance"], function(v) {//You need a separate string for each attribute you are getting. let resolve = parseInt(v.resolve,10)||0; let fortitude = parseInt(v.fortitude,10)||0; let endurance = parseInt(v.endurance,10)||0; let hp = 3 + fortitude + endurance; let nerve: 2 + fortitude + resolve; setAttrs({ hp: hpmax, nerve: nervemax }); }); }); </script> For the roll error, your problem is that negative dice rolls require there to be something before the roll, change your dice pool roll to this: {{abovezero=[[{0+[[@{athletics}+?{Modifier|0}]]d8!}>?{Target Number|4}f1]]}}
Oh ok. It's always something simple. Now all the rolls are working but my sheet worker still isn't. At least it's outputting an error to the console now, though only when I'm loading the editor. SyntaxError: Unexpected token : at eval (<anonymous>) at messageHandler
1555553600
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
For that error, run it through the google closure compiler . That will give you a line number and some more details on what it's finding. What that means though is that it is seeing a colon instead of something that it was expecting. If that's the entire error trace though, I'm not actually sure it's coming from your script. If the compiler doesn't give you anything, then try putting some console.log()'s in there to see what your various variables are being set to.
Oh yup, for some reason I put a colon instead of an equals at "let nerve" Thanks for all the help
1555557791
GiGs
Pro
Sheet Author
API Scripter
If the script is exactly as above you might have another problem.                         let hp = 3 + fortitude + endurance; let nerve: 2 + fortitude + resolve; setAttrs({ hp: hpmax, nerve: nervemax }); You have nerve: nervemax , and it should probably be nerve: nerve .
1555559247
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Good catch GiGs. Same for hp as a matter of fact.
1555562874
GiGs
Pro
Sheet Author
API Scripter
oh yes, haha. Funny that I spotted one and missed the other.
1555630863
vÍnce
Pro
Sheet Author
GiGs said: oh yes, haha. Funny that I spotted one and missed the other. Even funnier, I only saw those two issues but didn't have enough "js confidence" to post.   lol 
Previously I had it as nervemax: nervemax and hpmax: hpmax, (and let nervemax / let hpmax) but I changed it for some reason, probably while digging for the error. Why would that be a problem?
1555640656
GiGs
Pro
Sheet Author
API Scripter
In this                          let hp = 3 + fortitude + endurance; let nerve = 2 + fortitude + resolve; setAttrs({ hp: hpmax, nerve: nervemax }); In the setattr (hp: hpmax) the first  entry is the attribute on the character sheet, the second entry is the variable from your script. Your script uses hp as a variable, so that second entry needs to match it. At the moment there is no hpmax variable (and no nervemax variable), so your setattrs  function is setting the hp and nerve attributes to undefined values.
Oh ok I thought it was the other way around. Thanks all.