So, my friends and I play a table top role playing game that, for the purposes of this question, is functionally equivalent to any other table top role playing game. Each character has a set of stats, like ability scores, and defense scores, that are used by the game mechanics to determine the outcomes of actions. Lets call these ability scores. These scores can be set in the character sheet. However, there are spell effects, and also some character abilities, that can modify these scores, depending on whether they are active. Lets call them spell effects. Now, I already have a section where temporary modifiers can be added to adjust the character's ability scores. That's fine, but there are spell effects that are turned off and on so frequently, during the course of a combat, that updating these temporary modifiers becomes a drag on the game. What I'd like to do is create a repeating section of spell effect templates. So, whenever there's a spell effect that frequently affects your character, you handle this by adding an entry to this repeating section, which we'll call the repeating section of spell effects. Each instance of this repeating section has a field for each of your character's ability scores. Into those fields you can enter modifiers that will apply to your character's associated ability scores, adjusting them, depending on whether the spell effect is active. Each section will also have a toggle that you can use to indicate whether the spell effect is active. Now the toggle could be a checkbox, but I'd like to modify the button in the solution presented here: <a href="https://app.roll20.net/forum/post/8556606/collapsible-inside-repeating-section" rel="nofollow">https://app.roll20.net/forum/post/8556606/collapsible-inside-repeating-section</a> so that instead of making the button show or hide part of the UI, it would enable or disable the associated spell effect. As for how it would do that, my best idea so far is to tie a 0 to the off setting of the button, and a 1 to the on setting. That way I can just have a modifier = modifier * button_value. That way the modifier can always be in the final calculation of the ability score, but it will only affect the ability score if it is active. Toggle button aside, the real challenge is to sum up all of the modifiers of each type in the spell effects repeating section. So far I haven't managed to grasp the code to do this well enough to even attempt to code it. In case anyone does know how, let me give you a simple pseudo-code example interface to plug it into: // ability scores:
attr_strength
attr_armor_class
attr_initiative_modifier
// ability score sums (after spell effect have been applied):
attr_final_strength
attr_final_armor_class
attr_final_initiative_modifier
// spell effects repeating section:
<fieldset class="repeating_spelleffects">
<select id="cars">
<option value="0">Off</option>
<option value="1">On</option>
</select>
<input name="attr_strength_modifier" type="number">
<input name="attr_armor_class_modifier" type="number">
<input name="attr_initiative_modifier" type="number">
</fieldset>