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

Autocalc fields and repeating fields

1407886864
Finderski
Pro
Sheet Author
Compendium Curator
Is there a way to sum values from repeating fields? For example, if I have a repeating field for Armor, is there a way to get the total weight of all the armor pieces in a calc field?
1407889432
Sam M.
Pro
Sheet Author
Nope
You could do it with a modifiable formula in a sheet couldnt you? It would just mean each time you add a new repeating field you would have to update the formula to include the new weight attribute
Zepth said: You could do it with a modifiable formula in a sheet couldnt you? It would just mean each time you add a new repeating field you would have to update the formula to include the new weight attribute Modifying the formula would necessitate refreshing the sheet, and the formula would apply to everyone. The simplest way to handle sets of fields that need to be added together is just to add a number of rows in a table. Sure it makes the sheet longer, but then you can do math and API stuff on it without any consequence or complication. Or, alternatively, you could create an API-based roller that takes the following: A Numeric field representing how many items are in your repeatable table. A Total Field. A Roll Button (Possibly labeled "Calculate". Then what you would do is use String functions to get the Weight Fields in the repeating section, add them together and then update the Total numeric field. So, for example, if the Repeating Weight field is attr_ArmorWeight and the Repeating section is called repeating_armor, and you had four items in the list, you'd enter 4 in the "# of Items" field and then hit the Calculate button. The script would then page through repeating_armor_0_ArmorWeight, repeating_armor_1_ArmorWeight, repeating_armor_2_ArmorWeight, repeating_armor_3_ArmorWeight and total the values. Lastly it'd put the result into the Total field, which the players would have needed to enter a dummy number into first for the API to know the attribute exists. It's not clean, and there's no guarantee that this would work consistently, but this is the closest to an AutoCalc field for Repeating Tables that I can think of.
1407893126
Finderski
Pro
Sheet Author
Compendium Curator
Thanks, everyone.
Kevin S. said: Zepth said: You could do it with a modifiable formula in a sheet couldnt you? It would just mean each time you add a new repeating field you would have to update the formula to include the new weight attribute Modifying the formula would necessitate refreshing the sheet, and the formula would apply to everyone. I dont think it would, it would just require the player or the GM to add the new armour in the formula manually each time they add gear. It would be a pain in the ass but it would be doable. Create a disabled input box attr_armor-weight with a value of @{armor-calc} Then create a user editable input box attr_armor-calc. Whenever the player adds a new piece of armor they have to add the armor weight attribute to the calc. So the formula for the first piece of armour is simply @{repeating_armor_0_weight} when the player adds another piece the formula they change the formula to @{repeating_armor_0_weight} + @{repeating_armor_1_weight} and so on. It is messy and requires manual intervention but it is certainly doable.