Is this 4 d6 a completely separate roll, or something that is done alongside every other roll?
If it's a separate roll, you'd be better off putting it as a hidden attribute, and giving it a name you used to call it. like
<button type="action" class="hide" name="act_four"></button>
<input name="attr_four" type="hidden" value="0">
That creates a hidden attribute and action button, then just change the array:
const stats = [
'strength',
'dexterity',
'intelligence',
'wisdom',
'constitution',
'charisma',
'four'
];
and dont change the sheet worker at all - this would let you call a four dice button any time you want.
You can call this ability with %{CHARACTER-NAME|4}, replacing characetr_name which the character's actual name.
Or if clicking a token, use %{selected|four} or %{target|four}
If given the button class="hide" - thats just to show you'll have to use give it a class name and use CSS to hide it, like
button.hide {
display:none;
}
or
button.sheet-hide {
display:none;
}
(which of those is correct depends what CSS rule you are using for your sheet. Try both.)
You could add buttons for other rolls, like 3d6, 9d6, whatever.
Buttons Without Attributes
If you are creating a lot of standard rolls like that, it would be better to change the sheet worker a little bit to handle rolls without attributes attached, where you have one button which asks for the dice, and you roll that.
Add something like this to the html:
<button type="action" class="hide" name="act_ask"></button>
and change the sheet worker to account for this:
<script type="text/worker">
const stats = [
'strength',
'dexterity',
'intelligence',
'wisdom',
'constitution',
'charisma',
'four',
'ask'
];
stats.forEach(button => {
on(`clicked:${button}`, () => {
const roll_text = (button === 'ask') ?
`&{template:diceroll} {{name=?{How many Dice?|4} Dice}} {{roll=[[?{How many Dice?}d6]]}} {{high=[[0]]}} {{low=[[0]]}}` :
`&{template:diceroll} {{name=${button}}} {{roll=[[@{${button}}d6]]}} {{high=[[0]]}} {{low=[[0]]}}`
if(button === 'ask') {
}
startRoll(roll_text, (diceroll) => {
const total = diceroll.results.roll.result
const dice = diceroll.results.roll.dice; //This will be an array of the values rolled on all the dice
let total6s = dice.filter(d => d === 6).length;
let total1s = dice.filter(d => d === 1).length;
finishRoll(
diceroll.rollId, // this is where you save the computed values into something that can be passed to rolltemplates.
{
roll: total,
high: total6s,
low: total1s
}
);
});
});
});
</script>
Then when you call %{selected|ask} or whatever, you'll get prompted for hor many dice to roll.
You might remove the hidden class, and put this button somewhere prominant, and give it a name, so it can be clicked manually too.