You can do this a few ways but they all involve sheetworkers. You can assemble the roll with a sheetworker. Something like: on('change:opt_dodge_penalty',(event)=>{
getAttrs(['opt_dodge_penalty'],(attributes)=>{
const setObj = {};
if(+attributes.opt_dodge_penalty===1){
setObj.dodge_query = `- ?{Dodging gunfire?|> 50',0|10'-50',5|< 10',10 }`;
}else{
setObj.dodge_query = ''
}
});
}); This would require that you create an attribute to store the query in and reference it in the macro like so: {{Dodge=[[d20+@{dodge} - @{dodge_query}]]}} Note, I also took out the ,0d11 , as it didn't seem to have a purpose here. You could also use the new roll parsing capability and build the roll each time the action button is clicked. For this You'll need to change your roll button to an action button. Something like: <button type='action' name='act_dodge_roll'> And then the sheetworker looks like: on('clicked:dodge_roll',(event)=>{
getAttrs(['opt_dodge_penalty'],async (attributes)=>{
let roll = '&{template:your-template} {{fields=that you need}} {{Dodge=[[d20+@{dodge}';//Assemble our basic roll
if(+attributes.opt_dodge_penalty===1){
message += `- ?{Dodging gunfire?|> 50',0|10'-50',5|< 10',10 }]]}}`;//add the query if needed
}else{
setObj.dodge_query += ']]}}'//otherwise, just close the inline roll and roll template field
}
let roll = await startRoll(message);//send the roll, wait for the results of the roll
finishRoll(roll.rollId);//Once the results of the roll come back, tell the roll to submit to chat since we aren't doing any parsing of the roll results.
});
}); Edit: And actually, if you don't need opt_dodge_penalty to be a 0 or 1, then you could do this without sheetworkers as well by making the query the checked value of opt_dodge_penalty: <input type='checkbox' name='attr_opt_dodge_penalty' value='?{Dodging gunfire?|> 50',0|10'-50',5|< 10',10 }'> And then reference it like: {{Dodge=[[d20+@{dodge} - @{opt_dodge_penalty}]]}} but I'm assuming that you need it to be 0 or 1 for other reasons.