Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Use checkbox to dictate results for Roll Template

Hello all, I'm trying to work out the correct way to make a change to a roll result based on a checkbox. Specifically, if the checkbox is checked, I need to add another roll macro. Macro call is: &{template:magus} {{name=@{character_name}}} {{trait_name=@{trait1desc}}} {{result=[[{{@{dicepool}}>@{difficulty} + {@{trait1dice}}>@{difficulty}}]]}} and the template itself is: <rolltemplate class="sheet-rolltemplate-magus"> <table> <tr><th>{{name}}</th></tr> <tr><td>{{trait_name}} </td></tr> <tr> <td class="result">{{result}} Successes</td> </tr> </table> </rolltemplate> e.g. : If the box is unchecked, the macro should be: {{result=[[{{@{dicepool}}>@{difficulty} + {@{trait1dice}}>@{difficulty}}]]}} If the box is checked, the macro should be: {{result=[[{{@{dicepool}}>@{difficulty} + {@{trait1dice}}>@{difficulty} + {@{magicitem1dice}}>@{difficulty}}]]}} I'm open to alternative ways of doing this - I thought I could instead use the checkbox to control whether a section is shown or not, and always roll and display the extra dice separately, but I couldn't figure out the property logic. Any help is much appreciated!
1618115334
vÍnce
Pro
Sheet Author
Hi Duno, One option that should work(untested); Change the default macro to add the checkbox attribute. [[{{@{dicepool}}>@{difficulty} + {@{trait1dice}}>@{difficulty}} + @{checkbox_foo}]] Change the value of the checkbox ( usually  it's value="1" ) to the macro you want to include if checked. attr_checkbox_foo value="{@{magicitem1dice}}>@{difficulty}" So unchecked, checkbox_foo would be value="0" or "{@{magicitem1dice}}>@{difficulty}" if checked.
Hey Vince, thanks for the idea, but no go. I added a checkbox like so: <input type="checkbox" name="attr_magicitem1check" value="{{@magicitem1dice}}>@{difficulty}}"/> And added to the result: {{result=[[{@{dicepool}}>@{difficulty} + {@{trait1dice}}>@{difficulty} + @{magicitem1check}]]}} but that only ever returns 0 when unchecked and 1 when checked, I can't get it to return the dice roll results (and it doesn't seem to calculate it either - even if I say '2d4>1' it gives me a 1). Even worse, when it does return 1 (i.e. is checked) it doesn't add that 1 to count of successes. Wait a minute... That value's wrong. It should be: value="{@{magicitem1dice}}>@{difficulty}" and... hey, it works! Righteous. You're the best, Vince.