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

Repeating Sum Not Executing

Hi folks, novice creating my first custom sheet here. I am trying to have a repeating section to track items, weight (default 1) and total encumbrance (total weight), with a check box to make an items weight=2. I have implemented the repeating sum as per the wiki.  Removing an item works and updates the Total Encumbrance Total Encumbrance doesn't update when clicking Add in the repeating section or when clicking the checkbox. Any help understanding what's going on would be appreciated. Thanks! <fieldset class="repeating_inventory"> <span>Name</span>    <input type="text" name="attr_itemname"> <span>Bulky</span>     <input type="checkbox" name="attr_bulky" value="1"> <span>Weight</span> <input type="number" name="attr_itemweight" value="1 + 1 * @{bulky}" disabled> </fieldset> <br> <span>Total Encumbrance</span> <input type="number" name="attr_encumbrance_total" value="0"> <script type="text/worker"> Function as per the wiki, and the following worker: on('change:repeating_inventory:bulky change:repeating_inventory:itemweight change:repeating_inventory remove:repeating_inventory sheet:opened', function() {       repeatingSum("encumbrance_total","inventory","itemweight"); });
This recent known bug:&nbsp; <a href="https://app.roll20.net/forum/post/12070693/site-wide-roll20-bug-possibly-bugs" rel="nofollow">https://app.roll20.net/forum/post/12070693/site-wide-roll20-bug-possibly-bugs</a>
Ah right, I have been following that thread and thought the bug had been resolved.
1728189221

Edited 1728189283
GiGs
Pro
Sheet Author
API Scripter
That bug has been fixed, I think. I see something in your code that will definitely cause it to fail.&nbsp; Sheet workers cannot affect the totals of disabled inputs. They are two different things and are completely incompatible with each other. So this line: &lt;input type="number" name="attr_itemweight" value="1 + 1 * @{bulky}" disabled&gt; should be &lt;input type="number" name="attr_itemweight" value="0" readonly&gt; If you want itemweight to include a calculated value, you'll need to calculate it with a sheet worker. This should work (add this as a separate sheet worker): on('change:repeating_inventory:bulky', function() { getAttrs(['repeating_inventory_bulky'], function(values) { const bulky = +values.repeating_inventory_bulky || 0; setAttrs({ repeating_inventory_itemweight: 1 + 1 * bulky }); }); });
1728189474
GiGs
Pro
Sheet Author
API Scripter
I suggested a calculation for bulky, but I'm wondering if that repeating section does what you intend it to. As written now, items weigh either 1 or 2, and cannot be anything else.
Many thanks! That's making sense to me and it's working. The intention is to have only two weights. Items are weight 1, bulky items are weight 2.&nbsp; I made the weight value 1. &lt;input type="number" name="attr_itemweight" value="1" readonly&gt;