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/Sheetworker] I can't get this process to function

1537742604

Edited 1537742627
Leothedino
Sheet Author
Recently decided to brave the Sheet Worker as its very versatile, I've familiarised myself with its parts and the terminology (thank you w3schools), played with the examples  and got it working! Great!  ...problem, I then tried to write my own, and it's refusing to function. What have I missed here? <div class='sheet-mod-grid'>     <label class='sheet-extra-attack-title'>EXTRA ACTION</label><input type="number" name="attr_extra_action"><br />     <label class='sheet-joint-title'>JOINT (DUAL WIELD)</label><input type="number" name="attr_joint"> </div> <div class='sheet-grid-item'>     <input name='attr_mod_total' class='sheet-mod-total' type="number" value='@{mod_total}' disabled='true'> </div> <!-- SHEET WORKER --> <script type="text/worker"> on("sheet:opened change:extra_action change:joint", function() { getAttrs(["extra_action", "joint"], function(values) { var extra_action = parseInt(values["extra_action"],10)||0; var joint = parseInt(values["joint"],10)||0; var output = extra_action + joint; setAttrs({ "mod_total": output }); }); }); </script> <!-- END OF SHEET WORKER -->
1537744066
Andreas J.
Forum Champion
Sheet Author
Translator
I don't see what's wrong with it, but it's weird that "attr_ mod_total has the valye of itself, i.e value="@{mod_total"
1537744140

Edited 1537744586
Leothedino
Sheet Author
I am trying to get the final sum to appear in that field, should it not? The one that I got to work had this same layout. EDIT: So, that was the issue. I was under the impression from going through the forums that a Sheet Worker couldn't generate it's own attributes, so I thought it had to return to a pre-allocated one. Apparently not. 
1537775961
GiGs
Pro
Sheet Author
API Scripter
Sheet workers cant change disabled inputs. When you set disabled, it's basically for autocalc use only. Sheet workers can create attributes from scratch. If there is an attribute defined on the character sheet, it will change that value. If not, a new attribute will appear in the Attributes & Abilities tab of the character sheet. For the function you've created, an autocalc field is a lot simpler to code - something like: <input name='attr_mod_total' class='sheet-mod-total' type="number" value='[[@{joint}+@{extra_action}]]' disabled='true'> But if you want to use that value in other sheet workers, or have more complex math or logic going on, sheet workers are much better to use. 
1537776792
Jakob
Sheet Author
API Scripter
Leothedino said: I am trying to get the final sum to appear in that field, should it not? The one that I got to work had this same layout. EDIT: So, that was the issue. I was under the impression from going through the forums that a Sheet Worker couldn't generate it's own attributes, so I thought it had to return to a pre-allocated one. Apparently not.  If you want your mod total to be set by sheet workers and then only displayed, use a readonly  input, not a disabled  one. Disabled fields are autocalc fields and cannot be set by sheet workers readonly fields appear identical to the user, but they can be set by sheet workers.
1537789565

Edited 1537789783
Leothedino
Sheet Author
Ah, the more you know! Thanks for that, noted. I'll give it a go as I play more and more with these Sheet Workers. :D  And thanks GG, it was more that soon I have to make an 'Inventory' tab for my sheet with different bag types (each a different Repeating Section), these will all be summing up their weight to one 'total'. I knew auto-calc won't work for that, so thought it was time to get learning Sheet Workers.