I can't find a good tutorial on how the sheetworker parses repeating values. I've been working with some toy code, and I'm starting to see some values appearing, but I'm not sure how to implement anything yet. Hopefully you all can steer me in the right course. So, here is what I'm working with in this toy problem; A repeating field called repeating_powers A set of three radio buttons with values 0, 1, and 2 with the name attr_ranktype A final value to be calculated from all of the attr_ranktype radio buttons pressed. For our purposes, lets call the attribute it will be pass to as attr_foo Lets assume I only have five instances of my repeating table. Note that I know this example could be solved with the RepeatingSum function I'll link to at the end of this paragraph. The problem is that the lookups I have to do for my actual problem make using RepeatingSum not an option. But, if you come across this post looking for answers, check here first to see if it will work for you; <a href="https://wiki.roll20.net/RepeatingSum" rel="nofollow">https://wiki.roll20.net/RepeatingSum</a> Here is where I am so far, with comments on what I understand; HTML <fieldset class="repeating_powers">
//Some code here that is not important at this time
//A collection of my three radio buttons
<input type="radio" class="sheet-isDefault" value="0" name="attr_ranktype" checked> <span class='sheet-boxTitle'>Default Rank </span>
<input type="radio" class="sheet-isRank" value="1" name="arrt_ranktype"> <span class='sheet-boxTitle'>Power Rank </span>
<input type="radio" class="sheet-isBase" value="2" name="attr_ranktype"> <span class='sheet-boxTitle'>Baseline Rank </span>
//Some more code
</fieldset> JS on("sheet:opened change:repeating_powers:powerrank change:repeating_powers:powerrank change:repeating_powers:basecost change:repeating_powers:rankcost change:repeating_powers:baserankcost change:repeating_powers:baserankvalue change:repeating_powers:rankbasestat remove:repeating_powers", function(){
getSectionIDs("repeating_powers", function(idarray) {
//If I have no repeating powers, then just stop what I'm doing now and exit
if (idarray.length === 0) {
return;
}
//Build an array of my ranktypes
const fieldArray = [];
idarray.forEach(id => fieldArray.push(
`repeating_powers_${id}_ranktype`
));
//So, if I were to look at fieldArray[0], it would give me a value like
//"repeating_powers_-asdjfbniujsadk234klnlk34_ranktype" which is the unique
//row identifier
var firstRankTypeValue; //I eventually want to have this give me the value of my [0] element ranktype
var lastRankTypeValue; //I eventually want to have this give me the value of my [4] element ranktype
var sumRankTypeValue; //I eventually want to have this give me the value of my [0]-[4] elements in some sort of for loop
//From here, I have no idea how to actually pull the values correctly with a getAttrs and a setAttrs, though I know I have to use a function(values) with my getAttrs
});
}); Additionally, lets say at some point I need to do 2+ values in my fieldArray. Say, for example, I also need to pass the amount of dice I am rolling, as below; //Build an array of my ranktypes and die amounts
const fieldArray = [];
idarray.forEach(id => fieldArray.push(
`repeating_powers_${id}_ranktype`, `repeating_powers_${id}_dieamount`
)); How would this change getAttrs and setAttrs if I had a variable like... var diemoded; //A modded amount of dice where it is equal to ranktype * dieamount Sorry if this is a lot to ask, but hopefully my examples are helpful. Thanks in advance for any help!