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 .
×

Action buttons in repeating sections using attributes from inside repeating section

Hello, I've been trying to do something that should be super simple, but I cona't for the life of me find a place that explains the correct syntax for this. on("clicked:repeating_guns:shoot", function() { getAttrs(["heat", " repeating_guns_$X_gunHeat "], function(values) { let newHeat = parseInt(values.heat,10)||0; let gunHeat = parseInt(values.gunRecoil,10)||0; newHeat += gunHeat; setAttrs({"heat" : newHeat}); }); }); The repeating section "guns" has a button called "shoot" and a number called "gunHeat", which is supposed to be added to the "heat" value (outside of repeating section) when the button is pressed. I know that a specific value from a repeating section can be acessed by doing  repeating_guns_$X_gunHeat with X being the index (starting at 0) of the section, but in this case, the index is "unkown", as it is supposed to be the same index as of the button pressed. I feel like this should be easy, I just don't know what to in place of " repeating_guns_$X_gunHeat "
1589146545
GiGs
Pro
Sheet Author
API Scripter
You cant use this syntax "r epeating_guns_ $X _gunHeat " in sheet workers. It's shorthand that only works in chat and macros. This syntax works when being triggered from within the repeating section: r epeating_guns_ gunHeat . You have to use this on the value. line too. Another problem: your sheet worker calls a value called gunRecoil, should that be gunHeat? I;m guessing your sheet worker should be on("clicked:repeating_guns:shoot", function() { getAttrs(["heat", " repeating_guns_gunRecoil "], function(values) { let newHeat = parseInt(values.heat)||0; let gunHeat = parseInt(values. repeating_guns_gunRecoil )||0; newHeat += gunHeat; setAttrs({"heat" : newHeat}); }); }); or on("clicked:repeating_guns:shoot", function() { getAttrs(["heat", " repeating_guns_gunHeat "], function(values) { let newHeat = parseInt(values.heat)||0; let gunHeat = parseInt(values. repeating_guns_gunHeat )||0; newHeat += gunHeat; setAttrs({"heat" : newHeat}); }); }); I removed the radix from parseInt (the ,10) - thats not needed.
Thanks GiGs, that helps a lot. That thing with gunRecoil was a typo, the actually function is larger and I was making a dummy fuction for this post, but good eye notherless.