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

Combining two RepeatingSum Features

1598001813

Edited 1598001859
GM
Pro
This is a fairly newbie question as I am just getting into Javascripts.  I am using the RepeatingSum feature, which I have working great with Weight * Quantity for an inventory.  However, what I want to do is add a checkbox input to indicate if an item is carried or not.  The intention is for it to be easily to leave an item "off character" without much hassle.  Unfortunately, I can't seem to figure out how to make both this code and the item * weight work together.  The code examples from the Wiki I'm using I've posting below (I can get either to work, but not sure how to make them work in tandem): WEIGHT * QUANTITY on ( 'change:repeating_inventory remove:repeating_inventory' , function () { repeatingSum ( "encumbrance_total" ,"inventory",[ "item_weight" ,"item_number"]); }); WEIGHT * CARRIED CHECKBOX on ( 'change:repeating_armour remove:repeating_armour' , function () { repeatingSum ( "armour_weight" , "armour" ,[ "armour_piece" ,"armour_worn"]); }); Quick Summary: What formula would I use to effectively make Item_Weight multiplied by Item_Number multiplied by Item_Carried (Checkbox with a 0/1 result)?  Effectively, combining the two. Thanks again.  I'm not entirely understanding how Java does math or how this code works so have been trying to feel for a solution blind and have been unable to find a way to hybrid these solutions.
1598038544

Edited 1598038589
GiGs
Pro
Sheet Author
API Scripter
What is your repeating section called? In the example below I have assumed it is called repeating_gear , so you would need to replace gear  wherever it appears with whatever comes after repeating_ in your section. It's listed 3 times below - twice on the first line and once on the second line. on ( 'change:repeating_ gear remove:repeating_ gear ' , function () { repeatingSum ( "total_weight" , " gear " , [ "Item_Weight" , "Item_Number", "Item_Carried"]); }); the total_weight attribute at the start also needs replacing with the name of the attribute you want to hold the total weight/
Ah, that got it working perfectly!  Thank you very much for the help, it's working great now.  Extremely appreciated.
1598117122
GiGs
Pro
Sheet Author
API Scripter
great!