
I thought for sure this would be covered somewhere but I've been tinkering and researching for hours so I'm sorry if this is already covered. I have a repeating row and on that row is: A name field A number field (for rank) A text field that calculates a text based on the rank (1=d4, 2=d6, 3=d8, etc) via a sheet worker A roll button to roll the die that has already been correctly calculated with the sheet worker I am having trouble getting the roll button to reference the attribute that is calculated via sheet worker. <div>
<h1>Physique</h1>
<label>Physique:<input type="number" name="attr_physique" max="10" min="1" /><span name="attr_physique_die"></span></label>
<h3>Abilties</h3>
<fieldset class="repeating_pabil">
Name:<input type="text" name="attr_pabilname" /> Rank:<input type="number" name="attr_pabilrank" max="10" min="0" /><span type="text" name="attr_dice"></span><button type='roll' name='roll_phys' value='/roll ?{Amount of Effort}@{dice}kh1'>Roll</button>
</fieldset>
</div> The above code takes in the rank number and the sheet worker is posting the corresponding die to the attr_dice span and posting it so I can tell the sheet worker is doing its job and setting repeating_pabil_$n_dice to the correct value. However, the roll button won't appropriately use the attr_dice. Other threads have said that within the row, I should not have to specify the row index so @{dice} should reference the dice attribute from that row but I get an error saying that doesn't exist. If I use @{repeating_pabil_$0_dice} it will properly use the attribute I have set up but then I run into another problem where the next row also uses index 0. I can't figure out how to just make it reference the row that it's in one way or the other and I feel like I'm out of ideas for trying to fix it. Any advice would be appreciated. It seems like it should be really simple. Just in case it is relevant this is my sheetworker: // Calculate Die for each Physique Ability
on("change:repeating_pabil:pabilrank", function() {
getAttrs(["repeating_pabil_pabilrank"], function(values) {
setAttrs({ repeating_pabil_dice: GetDice(values.repeating_pabil_pabilrank)
});
});
}); and the accompanying GetDice() function: // Function to determine dice value //
function GetDice(level) {
let die="";
if (level <=1) { die='d4'; }
else if (level <=2) { die='d6'; }
else if (level <=3) { die='d8'; }
else if (level <=4) { die='d10'; }
else if (level <=10) { die='d12'; }
return die;
}