In your first post, you showed wanting to mark specific attributes (heartused and acuityused) as checked. But in your most recent reply, you mention wanting to check the gearused attribute. I did the below based on the OP description of what attributes to check. I'll note that in your demo code, all the gearused checkboxes have the same checked value, so you'll want to change that if you actually want to manipulate those. Also, with the action button method, you only need a single button instead of one for each roll type because the sheetworker dynamically constructs the roll based on the state of the item. <fieldset class="repeating_belongings">
<input type="text" name="attr_gear" style="width:125px;">
&nbsp;&nbsp;<input type="checkbox" name="attr_gun" value="1"><span></span>
<select name="attr_gearquality" style="width:175px;">
<option value="0">--quality--</option>
<option value="1">Crap: 1d4</option>
<option value="2">Normal: 1d6</option>
<option value="3">Normal & Excellent: 2d6</option>
<option value="4">Big: 1d8</option>
<option value="5">Big & Excellent: 2d8</option>
</select><!-- Was missing the closure to the select tag here -->
<!-- Note I've removed these control inputs to shorten the code. You may not even need them when using the action button/CRP method -->
<div class="sheet-sishow-SI0"></div>
<div class="sheet-sishow-SI2"><button type="action" name="act_gearRoll">Roll</button>&nbsp;&nbsp;<input type="checkbox" name="attr_gearused" value="1"><span></span> </div>
</fieldset>
<<script type="text/worker">
//Utility function from the K-scaffold. Parses out the section name, row id, and attribute name from an event's triggerName or sourceAttribute.
const parseTriggerName = function(string){
let match = string.replace(/^clicked:/,'').match(/(?:(repeating_[^_]+)_([^_]+)_)?(.+)/);
match.shift();
return match;
};
on('clicked:repeating_belongings:gearroll',(event)=>{
//Get our row information; we may not need all of this, but showing how you'd get all of it.
//section = `repeating_belongings`; rowID = the rowID; buttonName = gearroll
const [section,rowID,buttonName] = parseTriggerName(event.triggerName);
//The callback for this getAttrs is going to be async so that we can use the async/await pattern with startRoll
getAttrs([`repeating_belongings_${rowID}_gearquality`],async (attributes)=>{
//Convert the value to a number
attributes[`repeating_belongings_${rowID}_gearquality`] = +attributes[`repeating_${rowID}_gearquality`];
//array to use to lookup how many dice of what size to roll
const diceLookup = [
{size:4,multiplier:1},
{size:6,multiplier:1},
{size:6,multiplier:2},
{size:8,multiplier:1},
{size:8,multiplier:2},
];
//Extract the appropriate details
const dieDetails = diceLookup[attributes[`repeating_belongings_${rowID}_gearquality`] - 1];
if(!dieDetails) return; //If there are no details, then don't send a message
//Construct our message. The roll has to be in a roll template for CRP to work.
const message = `&{template:default} {{name=@{repeating_belongings_${rowID}_gear}}} {{Roll=[[[[(1 - @{repeating_belongings_gearused}) * ${dieDetails.multiplier}]]d${dieDetails.size} + [[(1 - @{repeating_belongings_gearused}) * @{repeating_belongings_gun}]]d4]]}}`;
//Send the roll, and wait for the results to come back
const result = await startRoll(message);
finishRoll(result.rollId);//We aren't doing any manipulation of the roll, so we can just finish it right away
setAttrs({//Set your attributes
heartused: 1,
acuityused: 1
});
});
});
</script> EDIT: Had forgotten to include the repeating row details for calling gearused and gun in the message