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

Using checkboxes to show/hide sections of roll templates.

I've run into an issue with creating roll templates. I've created a checkbox which is a 0 or 1, essentially a yes or no. I know its possible to use {{#rollTotal() name_here 1}} but it doesnt seem to be working for checkboxes. Nor does {{#name_here}} foo {{/name_here}}. I have seen this in use on the 5th Edition template with the spells and class actions and thats basically what I'm trying to do. But, I don't understand the code well enough, and I suspect he is handling the display of the roll template tables in a way that wouldn't be compatible with what I'm doing. PS. I'm sorry if I'm not very clear. I'm not exactly sure myself so explaining what I am after is a bit dodgy. <input type="checkbox" name="attr_spellshowinfoblock" value=""/> {{#spellshowinfoblock}} <tr><td><span>Casting Time </span>{{casting_time}}</td></tr> <tr><td><span>Components </span>{{components}}</td></tr> <tr><td><span>Range </span>{{range}}</td></tr> <tr><td><span>Target </span>{{target}}</td></tr> <tr><td><span>Duration </span>{{duration}}</td></tr> {{/spellshowinfoblock}}
1429022407
Kryx
Pro
Sheet Author
API Scripter
spellshowinfoblock needs to be sent to the roll template. Example: <button type="roll" class="sheet-roll" name="roll_npc_lair_action_1" value="@{output_option} &{template:5eDefault} {{npc_action=1}} {{title=@{npc_lair_action_name_1}}} {{subheader=@{character_name}}} {{subheaderright=@{npc_lair_action_type_1} attack}} @{npc_lair_action_macro_options_1}">Lair 1</button> In that example npc_action, title, subheader, etc are all variables that the template can parse. In your case you need to do: {{varNameHere=@{spellshowinfoblock}}} And then in your template: {{#varNameHere}} STUFF {{/varNameHere}} There may be other ways to do it, but that's how I've always done it
That's how I've been trying and nothing seems to happen.
1429046450
Finderski
Plus
Sheet Author
Compendium Curator
Have you tried something like: {{#rollTotal() name_here 1}} STUFF {{/rollTotal()}} and then sending: {{name_here=[[1d0+@{spellshowinfoblock}]]}} I don't know if that will work or not, a checkbox is not the same as a roll, so perhaps using rollTotal without a roll won't work?
1429057584
Lithl
Pro
Sheet Author
API Scripter
#rollTotal() should simply check the final value of the inline roll. You shouldn't even need the d0 in there.
@G.V. rollTotal() will not work, I've tried. And, for what you are describing, at least for similar arithmetic only, I've always used 0d0 it seems to have less issues. But its a good thought, I use that for my attack roll roll template. Here is the checkbox code: <input type="checkbox" name="attr_spellinfoblock" value="{{show-spellinfoblock=1}}"/> Here is the template code: &{template:35Adv_spell} {{name=@{spellName}}}{{spl_attack=@{spellatkroll}}} {{show-spellinfoblock=@{spellinfoblock}}} {{atk_target=@{spellatkroll}}}{{spell_target=@{spellatkroll}}} {{infolink=@{spellinfoLink}}} {{school=@{spellSchool}}} {{spell_fail=@{spellclass-1-spellfail} }} {{spell_chk=[[{1d100}>@{arcanespellfailure}]] }} {{succeedcheck=You are able to cast!}} {{failcheck= You Fail casting spell!}} {{level= @{spellclass-1-name} 1}} {{casting_time=@{castingTime}}} {{components=@{compAbbr}}} {{range=@{spellRange}}} {{target=@{targetArea}}} {{duration=@{spellDuration}}} {{saving_throw=@{saveDC}}} {{sr=@{spellResist}}} {{spl_display=@{spellrollStyle}}} {{damage=@{spellrollStyle}}} {{spell_description=@{description}}} {{spell_components=@{components}}} Bold text is the relevant section. Here is the template html: <rolltemplate class="sheet-rolltemplate-35Adv_spell"> <div class="sheet-wrapper"> <div class="sheet-border"> <table> <tr><th>{{name}}</th>{{#infolink}}<th class="sheet-info">[i]({{infolink}})</th>{{/infolink}}</tr> {{#spl_attack}} <tr><td><span class="tcat">on </span>{{spell_target}}</td></tr> <tr class="arrow-container"><td><div class="arrow-left"></div></td></tr> {{/spl_attack}} <tr><td><span class="tcat">School </span>{{school}}; <span class="tcat">Level </span>{{level}}</td></tr> {{#spell_fail}} <tr><td><span class="tcat">Spell Fail </span>  {{spell_chk}} {{#rollTotal() spell_chk 1}} <span class="hroll">{{succeedcheck}}</span> {{/rollTotal() spell_chk 1}} {{#rollTotal() spell_chk 0}} <span class="hroll">{{failcheck}}</span> {{/rollTotal() spell_chk 0}} </td></tr> {{/spell_fail}} {{#show-spellinfoblock}} <tr><td><span class="tcat">Casting Time </span>{{show-spellinfoblock}}{{casting_time}}</td></tr> <tr><td><span class="tcat">Components </span>{{components}}</td></tr> <tr><td><span class="tcat">Range </span>{{range}}</td></tr> <tr><td><span class="tcat">Target </span>{{target}}</td></tr> <tr><td><span class="tcat">Duration </span>{{duration}}</td></tr> {{/show-spellinfoblock}} <tr><td>{{#saving_throw}}<span class="tcat">Save </span>{{saving_throw}}; {{/saving_throw}}<span class="tcat">SR </span>{{sr}} vs SR</td></tr> {{#spl_attack}} <tr><td><span class="tcat">Attack </span>{{spl_attack}} vs {{atk_target}}</td></tr>{{/spl_attack}} <!-- #dam_display and #damage must both have a value in order for this section to show --> {{#spl_display}} <tr><td><span class="tcat">Damage: </span>{{spl_display}} {{#damage}}({{damage}}){{/damage}}</td></tr> {{/spl_display}} <tr><td>{{spell_description}}</td></tr> <tr><td><span class="tcat">Cost to Cast </span>{{spell_components}}</td></tr> {{#extra_line1}} <tr><td>{{extra_line1}}</td></tr>{{/extra_line1}} </table> </div> </div> </rolltemplate> No amount of work gets this to show or hide the require section, it just ALWAYS shows it. Which is not what I want. So, I guess I'm not understanding how you are all explaining it. Because its not working. PS I've also tried {{show_spellinfoblock}}. Which causes the chatbox to vanish entirely.
1429064555
Finderski
Plus
Sheet Author
Compendium Curator
The only other thing I could recommend would be something like: <input type="checkbox" name="attr_spellinfoblock" value="1"/> And use the {{#rollWasCrit() show-spellinfoblock}} STUFF {{/rollWasCrit()}} And the call could be something like: {{show-spellinfoblock=[[@{spellinfobblock}d1]]}} I've been told that a d1 always crits and always fumbles, so if spellinfoblock is either 0 or 1, if it's one it would be crit automatically. In theory that would work, but I haven't messed around with it too much, myself, yet.
No. None of these seem to work for me. I don't really know what to make of this, and it is quite frustating because I want this for a reapeating section. The same basic "code" which will be used for several different repeating sections so its not really like I can move on from this.
1429129750
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Toby, I think you're overcomplicating your roll template macro. Your checkbox will either return 0 if it's not checked or it will return {{show-spellinfoblock=1}} If it's 0 outside of {{}} it will be ignored. However if it's checked what it actually expands up to being in your macro is {{show-spellinfoblock=@{spellinfoblock}}} => {{show-spellinfoblock={{show-spellinfoblock=1}}}} This isn't what you want. You just want @{spellinfoblock} independent of anything else in the macro. IE &{template:35Adv_spell} {{name=@{spellName}}}{{spl_attack=@{spellatkroll}}} @{spellinfoblock} {{atk_target=@{spellatkroll}}}{{spell_target=@{spellatkroll}}} {{infolink=@{spellinfoLink}}} {{school=@{spellSchool}}} {{spell_fail=@{spellclass-1-spellfail} }} {{spell_chk=[[{1d100}>@{arcanespellfailure}]] }} {{succeedcheck=You are able to cast!}} {{failcheck= You Fail casting spell!}} {{level= @{spellclass-1-name} 1}} {{casting_time=@{castingTime}}} {{components=@{compAbbr}}} {{range=@{spellRange}}} {{target=@{targetArea}}} {{duration=@{spellDuration}}} {{saving_throw=@{saveDC}}} {{sr=@{spellResist}}} {{spl_display=@{spellrollStyle}}} {{damage=@{spellrollStyle}}} {{spell_description=@{description}}} {{spell_components=@{components}}}
1429132008

Edited 1429132020
Toby
Pro
Um... Wow.. so... simple. How exactly did I spend three days and never try that...... *sputters* Wut.... Well thank you, it worked.
1429133272
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Well thank you, it worked. Awesome :) Happy rolling!