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

Sheetworker help required...

Greetings....I have been staring at this sheetworker for so long I am now blind to the error...     on('change:skacrobatics change:skacrobaticsxp sheet:opened', function () {         getAttrs(['dex','skacrobaticsxp'], function(v) {             const dex = v.dex *1||0;             const skacrobatics = v.skacrobatics *1||0;             const skacrobaticsxp = v.skacrobaticsxp *1||0;             const skacrobaticsa = Math.round(dex/5 + 9);             const skacrobaticsb = Math.round(skacrobaticsxp/2);             const skacrobaticsroll = Math.round(skacrobaticsa + skacrobaticsb);             setAttrs({                  skacrobatics: skacrobatics                  skacrobaticsxp: skacrobaticsxp                  skacrobaticsroll: skacrobaticsroll             });         });     }); My output for skacrobaticsroll is giving me a blank value...can anyone see the problem?
1596859940

Edited 1596860270
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
the code seems correct are you sure you didn't set the skacrobaticsrolls input as disabled? sheet workers cannot edit a disabled input . If you want to use a sheetworker to create a value that is displayed but cant be edited, set the input to readonly . this looks the same as disabled, and cant be edited, but sheetworkers can update it. I'm asking cause you said the value is blank and not, for example 0, and I had that problem before when I set my sheet input as disabled. EDIT: also just to be sure I would use parseInt before the logical or   const skacrobatics = parseInt(v.skacrobatics)||0; So if parseInt return a value it would use that otherwise it would use 0
Here is the associated HTML         <div>             <input class="field40 center" type="checkbox" name="attr_skacrobatics" value="1" unchecked>             <div class="field10"></div>             <div class="field130 left">Acrobatics</div>             <input class="field40 center" type="number" name="attr_skacrobaticsxp" value="0">             <div class="field10"></div>             <input class="field40 center" type="number" name="attr_skacrobaticsroll" value="" readonly>         </div>
1596866855
Kraynic
Pro
Sheet Author
I'm not sure about the rest, but your first 2 lines in the SetAttrs section should end with a comma:             setAttrs({                  skacrobatics: skacrobatics,                  skacrobaticsxp: skacrobaticsxp,                  skacrobaticsroll: skacrobaticsroll             });
1596868828
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
I had the on("change:dex") for simplicity, you can remove it Input <script type="text/worker"> // === ATTRIBUTE ARRAYS on('change:dex change:skacrobatics change:skacrobaticsxp sheet:opened', function () { getAttrs(['dex','skacrobaticsxp'], function(v) { const dex = parseInt(v.dex)||0; const skacrobatics = parseInt(v.skacrobatics)||0; const skacrobaticsxp = parseInt(v.skacrobaticsxp)||0; const skacrobaticsa = Math.round(dex/5 + 9); const skacrobaticsb = Math.round(skacrobaticsxp/2); const skacrobaticsroll = Math.round(skacrobaticsa + skacrobaticsb); setAttrs({ skacrobatics: skacrobatics, skacrobaticsxp: skacrobaticsxp, skacrobaticsroll: skacrobaticsroll }); }); }); </script> <div> <input class="field40 center" type="checkbox" name="attr_skacrobatics" value="1" unchecked> <div class="field10"></div> <div class="field130 left">Acrobatics</div> DEX <input class="field40 center" type="number" name="attr_dex" value="0"> Acrobatics <input class="field40 center" type="number" name="attr_skacrobaticsxp" value="0"> <div class="field10"></div> <input class="field40 center" type="number" name="attr_skacrobaticsroll" value="" readonly> </div> Output I suspect the problem was either using  const dex= v.dex *1 || 0 (cause v.dex will not give you a false value, while using parseInt, any NaN or 0 is considered a falsy value, so they will trigger the or condition) or as Kraynic said, the fact you forgot the comma in the setAttrs function.
Ok....it's still not working...I'm buggered if I can see what's wrong.... Here is the HTML...         <div>             <input class="field40 center" type="checkbox" name="attr_skacrobatics" value="1" unchecked>             <div class="field10"></div>             <div class="field130 left">Acrobatics</div>             <input class="field40 center" type="number" name="attr_skacrobaticsxp" value="0">             <div class="field10"></div>             <input class="field40 center" type="number" name="attr_skacrobaticsroll" value="" readonly>         </div> Here is the sheetworker...     on('change:dex change:skacrobatics change:skacrobaticsxp sheet:opened', function () {         getAttrs(['dex','skacrobaticsxp'], function(v) {             const dex = parseInt(v.dex)||0;             const skacrobatics = parseInt(v.skacrobatics)||0;             const skacrobaticsxp = parseInt(v.skacrobaticsxp)||0;             const skacrobaticsa = Math.round(dex/5 + 9);             const skacrobaticsb = Math.round(skacrobaticsxp/2);             const skacrobaticsroll = Math.round(skacrobaticsa + skacrobaticsb);             setAttrs({                  skacrobatics: skacrobatics,                  skacrobaticsxp: skacrobaticsxp,                  skacrobaticsroll: skacrobaticsroll             });         });     }); And here are the attributes in the "Attributes and Abilities" tab...note, there is no "skacrobaticsroll" attribute...  :'( Here is the screenshot of the output... My head is pounding and my eyes are crossed...  :'(
1596879230
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Mmmh... do you have any other script? The weird thing of roll20 is that if there is an error in one script,&nbsp; none of the script would work... so theoretically you might be tring to debug the correct code without finding the problemstic one. If you are using chrome, my suggestion is adding a lot of console.log messages to see where the code fails <a href="https://developers.google.com/web/tools/chrome-devtools/console/log" rel="nofollow">https://developers.google.com/web/tools/chrome-devtools/console/log</a>
Marco M. said: Mmmh... do you have any other script? The weird thing of roll20 is that if there is an error in one script,&nbsp; none of the script would work... so theoretically you might be tring to debug the correct code without finding the problemstic one. If you are using chrome, my suggestion is adding a lot of console.log messages to see where the code fails <a href="https://developers.google.com/web/tools/chrome-devtools/console/log" rel="nofollow">https://developers.google.com/web/tools/chrome-devtools/console/log</a> Ahhhh...I have dozens of scripts....I will look into that...cheers
Eureka!!!!! Another script had the commas missing.... THANKS EVERYONE....it's now working fine&nbsp; :D&nbsp; :D&nbsp; :D