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

Problem with updating fields in a worker.

1608890435
Senjak
Pro
Sheet Author
I'm having a problem updating a field with a worker script and have been beating my head against this for quite some time.  I **think** I'm following the examples correctly; however, it just isn't doing what I want.  I'm so frustrated with this that I've reduced the problem down to the most basic form in an attempt to get it working with out any better results.  I'd love any help you guys can offer. My code: <!-- Start of Everything HTML --> <div> <!-- drop down to select the armor type from a list -->   <select name="attr_armor_type">     <option selected value="0">0</option>     <option value="1">1</option>     <option value="2">2</option>     <option value="3">3</option>     <option value="4">4</option>     <option value="5">5</option>   </select> This is where you select the armor type. <!-- all below this point should get updated on sheet open and update of armor type -->   <br>   <input type="text" readonly="readonly" value=0 name="attr_armor_type">And here is the armor type you selected.   <br>   <input type="text" readonly="readonly" value=0 name="attr_armor_value">And here is the armor value you selected. </div> <!-- End of Everything HTML --> <script type="text/worker">   on("change:armor_type sheet:opened", function(eventInfo) {     getAttrs(["armor_type"], function(values) {       let at = parseInt(values.armor_type)||0;       let av = at + 10;       setAttrs ({         armor_value: av       });     }   } </script> One drop down menu.  Its value is correctly shown and updated in the read only field.  I want to call a worker script every time the drop down is update and change the value by 10.  (I did say that I dumbed it down!) As much as I've tried, I can't get the second field to update. Again, thanks for any help and suggestions that you can offer. Senjak
1608893118
GiGs
Pro
Sheet Author
API Scripter
In your sheet worker us, the on and getAttrs functions aren't closed propely. They need to end with }); not } Try this: on("change:armor_type sheet:opened", function(eventInfo) {     getAttrs(["armor_type"], function(values) {         let at = parseInt(values.armor_type)||0;         let av = at + 10;         setAttrs ({             armor_value: av         });     }); }); See the last two lines, and compare them to your worker.
1608922302
Senjak
Pro
Sheet Author
Thank you!  I'd suspected that it was something simple, I just wasn't seeing it (too many years coding C when I was younger!)