There's no way to have conditional elements in a macro. You cant have "if something is not 0, do this" within the macro. What you can do though, since you are making the character sheet, is build the macro in a sheet worker. Until that roll button is clicked, the macro is just text, and you can manipulate it with sheet worker programming, So what you would need to do is create a hidden attribute to hold the button text, and replace the button code above with a reference to this attribute. Like so value="/roll @{button_text}d10 (@{character_name} - empathy test)"/> And then your hidden attribute would be <input type="hidden" name="attr_button_text" value="[[@{Empathy}+@{Social_Pos1}+@{Social_Pos2}-@{Social_Neg1}-@{Social_Neg2}+ ?{modifier|0}]]"> Now you create a sheet worker which responds to the SocialPos/Neg checkboxes, and replaces the button_text attribute's value with the contents you want in the button. on("change:socialpos1 change:socialneg 1 change:socialpos2 change:socialneg 2 sheet:opened", function () { getAttrs(['SocialPos1','SocialPos2','SocialNeg1','SocialNeg2'], function(values) { const pos1 = parseInt(values.SocialPos1)||0; const neg1 = parseInt(values.SocialNeg1)||0; const pos2 = parseInt(values.SocialPos2)||0; const neg2 = parseInt(values.SocialNeg2)||0;
let macro = "[[@{Empathy}";
if(pos1) macro = macro + "+@{Social_Pos1}";
if(pos2) macro = macro + "+@{Social_Pos2}";
if(neg1) macro = macro + "-@{Social_Neg1}";
if(neg2) macro = macro + "-@{Social_Neg2}";
macro = macro + "+ ?{modifier|0}]]";
setAttrs({ button_text: macro }); }); }); Untested, but that's the basic method you can use. There arer much more compact ways to write this worker, but this is easier to follow what's happening. if(pos1) only runs the statement afterwards, if pos1 is not equal zero. If its zero, it ignores the rest of that line.