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 .
×
May your rolls be chill this holiday season!
Create a free account

Using one attribute in a repeating section to modify another in the same repeating section

1599804473

Edited 1599804616
In my repeating section, I have a value I want to display.  I don't have much space though, so I want to use that value as the label for a button.  Unfortunately, the value is stored as an Int and needs to have a unit attached in order to make sense to the user.  So I added another attribute in the same repeating section, and wrote a function to take the value from one attribute, concatonate a label onto it, and store it in the new attribute, which I'll then use as the button label. Unfortunately, I'm pretty sure that what's happening is that the concatonated value is being stored outside the repeating section.  So instead of one for every instance of the repeating section, there is only one value.  So, I'm working on fixing it, but the examples I have in my code and that I've found in the forums are quite a bit more complicated than what I'm trying to do, so I haven't made sense of them yet. This is the code.  It is running, so I don't think there's a need to include the repeating section itself here, because all of the information needed is already in the code below. // add resource labels on('change:repeating_defenses:defense_action_points_clean', () => { getAttrs(['repeating_defenses_defense_action_points_clean'], values => { const def_act_pnts = "AP: " + int(values.repeating_defenses_defense_action_points_clean); console.log( 'add resource labels' + '\n', 'defense_action_points: ' + def_act_pnts ); setAttrs({defense_action_points: def_act_pnts}); }); });
1599806788
GiGs
Pro
Sheet Author
API Scripter
It would be clearer if you also provided the html for the repeating section. But the important question is: is the attribute you are changing on the same row as the attribute in the on(change) line? If so, you just need to add the repeating section name to setAttrs, like so setAttrs({     repeating_defenses_defense_action_points: def_act_pnts });
Well that is brilliant, and it works perfectly!  Thank you very much GiGs = ). Somehow, no matter how much I learn, every time I learn something new it feels like I've learned a new magic spell, but like in real life, or at least in real cyberspace = ).
1599810586
GiGs
Pro
Sheet Author
API Scripter
Great!