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

Hide/Show sections of a roll template with a checkbox

1719527963

Edited 1719528034
I've been trying to have text show up on a roll template, right next to the title that says "FRONT"  But everytime the checkbox isn't toggled, it instead says "0" instead of hiding it. All I want is to show text saying "Front" next to the title of my roll template when my checkbox is ticked, and hide it when it's not. Fyi I have pro, I am typing this on a different account. Thanks!
1719574189

Edited 1719574398
GiGs
Pro
Sheet Author
API Scripter
Are you creating your own sheet, or using one as a player? If creating your own sheet, you need to pass the value of the attribute to the rolltemplate. It does not know anything about the sheet - you need ro tell it the values you want it to know about. You can do this by creating  a key like {{front=[[0]]}} or {{front=[[1]]}} - or choose ot to pass it at all. You can respond to those events with RollTemplate Helpers. If using a sheet as a player, you are limited to how the template is meant to behave.
1719592388

Edited 1719592452
I'm creating a sheet.  How I have it set up is I have a checkbox with attribute named front <input type="checkbox" name="attr_front" value="1"> And I have a rolltemplate I'm trying to have it appear in if the checkbox is activated <rolltemplate class="sheet-rolltemplate-custom2">  {#front} Example {/front} </rolltemplate> And heres the roll: &{template:custom2} {{title=@{atkname} @{front}}}  Whenever the checkbox is not active, it displays a 0, I just want it to dissapear, not show anything.
1719599325

Edited 1719599381
vÍnce
Pro
Sheet Author
Joel N. said: I'm creating a sheet.  How I have it set up is I have a checkbox with attribute named front <input type="checkbox" name="attr_front" value="1"> And I have a rolltemplate I'm trying to have it appear in if the checkbox is activated <rolltemplate class="sheet-rolltemplate-custom2">  {#front} Example {/front} </rolltemplate> And heres the roll: &{template:custom2} {{title=@{atkname} @{front}}}  Whenever the checkbox is not active, it displays a 0, I just want it to dissapear, not show anything. Try changing the roll template to only show front's value if the roll is 1.  ie only show if checked example; &{template:custom2} {{title=@{atkname}}} {{front=[[@{front}]]}} <rolltemplate class="sheet-rolltemplate-custom2"> {{#title}}{{title}}{{/title}} {{#rollGreater() front 0}} FRONT {{/rollGreater() front 0}} </rolltemplate>
1719599715
GiGs
Pro
Sheet Author
API Scripter
This might be revealing something I don't. I didn't realise rolltemplates could recognise the values of an attribute. I'll have to explore the possibilities that opens up. However, a checkbox has a value of 0 when not selected, so you can't do it that way. By the way, shouldn't this line {#front} Example {/front} instead be {{#front}} Example {{/front}} The way I would normally handle something like this is either pass the checkbox value in a roll, or not pass it when you don't want it to show. For example: &{template:custom2} {{title=@{atkname} }} {{front=[[@{front}]]}} or (same thing): &{template:custom2} {{title=@{atkname} }} {{front=[[1]]}} And then when you don't want it to show: &{template:custom2} {{title=@{atkname} }}  Then you can use this method: {{#front}} Example {{/front}} That will show up only when {{front= exists, and won't show up if it doesn't.
1719599804
GiGs
Pro
Sheet Author
API Scripter
Oh yes, rollGreater() or rollTotal() or the other helpers are great - since a checked attribute always has a value.
Ah, I tried both your methods and they don't seem to work with what I'm trying to do. If a checkbox won't work, could I do the desired effect with a radio instead? Basically, I'm just trying to have a button on the character sheet, that when ticked, will add the text "Front" onto a roll template. When it's not clicked, it remains the same. I want to use this to give a better visualizer to players who are in the front of the party that they have less AC. Just as a reminder for whenever they roll, i suppose. I can't use two roll templates in this instance because the roll is attached to custom set up moves on the sheet, where you can make your own moves, set up damage ect. When you click on the move, it does the roll that was set up.
1719603064

Edited 1719603077
vÍnce
Pro
Sheet Author
This "limited" test worked for me; Front:<input type="checkbox" name="attr_front" value="1"> <button type="roll" name="roll_test" value="&{template:custom2} {{title=@{atkname}}} {{front=[[@{front}]]}}">Roll</button> Name:<input type="text" name="attr_atkname" value="" /> <rolltemplate class="sheet-rolltemplate-custom2"> {{#title}}{{title}}{{/title}} {{#rollGreater() front 0}} FRONT {{/rollGreater() front 0}} </rolltemplate> first roll is unchecked, second roll is checked
1719606438

Edited 1719606588
So it seems to work, but it adds a duplicate roll for some reason whenever {{front=[[@{front}]]}} is added into the roll template. here's the full roll:                                                                                         <button type="roll" id="roll_attack2" name="roll_attack" value="&{template:custom2} {{front=[[@{front}]]}} {{title=@{atkname}}} {{roll=[[@{dmgbase}+@{dmgattr}-3]]}} {{desc=@{atk_desc}\n[Roll Damage](`/roll @{dmgdone})}}">
1719608357

Edited 1719608382
vÍnce
Pro
Sheet Author
The roll macro looks fine, so I'm guessing that something in the custom2 roll template in relation to {{front}} is causing the duplicate. Can you post custom2?
Sure, thanks for helping me by the way. Here's custom2: &lt;rolltemplate class="sheet-rolltemplate-custom2"&gt; &nbsp; &nbsp; {{#rollWasCrit() roll}} &nbsp; &nbsp; &nbsp; &nbsp; &lt;img src="<a href="https://i.imgur.com/QtT1eQR.png" rel="nofollow">https://i.imgur.com/QtT1eQR.png</a>" style="display: block; margin-left: auto; margin-right: auto; width: 90%;margin-bottom:10px"&gt; &nbsp; &nbsp; {{/rollWasCrit() roll}} &nbsp; &nbsp; {{#rollWasFumble() roll}} &nbsp; &nbsp; &nbsp; &nbsp; &lt;img src="<a href="https://i.imgur.com/SB0vhEq.png" rel="nofollow">https://i.imgur.com/SB0vhEq.png</a>" style="display: block; margin-left: auto; margin-right: auto; width: 30%;margin-bottom:10px"&gt; &nbsp; &nbsp; {{/rollWasFumble() roll}} &nbsp; &lt;div class="sheet-container sheet-color-{{color}}"&gt; &nbsp; &nbsp; &lt;div class="sheet-header"&gt; &nbsp; &nbsp; &nbsp; {{#title}}&lt;div class="sheet-title"&gt;&lt;img src="<a href="https://i.imgur.com/hAht1WW.png" rel="nofollow">https://i.imgur.com/hAht1WW.png</a>" style="width: 15%;margin-right:10px"&gt;{{title}}&lt;/div&gt;{{/title}} &nbsp; &nbsp; &nbsp; {{#rollGreater() front 0}} &nbsp; &nbsp; &nbsp; &nbsp; FRONT &nbsp; &nbsp; &nbsp; {{/rollGreater() front 0}} &nbsp; &nbsp; &nbsp; {{#subtitle}}&lt;div class="sheet-subtitle"&gt;{{subtitle}}&lt;/div&gt;{{/subtitle}} &nbsp; &nbsp; &lt;/div&gt; &nbsp; &nbsp; &lt;div class="sheet-content"&gt; &nbsp; &nbsp; &nbsp; {{#allprops() title subtitle desc color}} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="sheet-key"&gt;{{key}}&lt;/div&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="sheet-roll"&gt;&lt;span style="font-size: 20px;font-weight:bolder;padding-right:15px;font-color:black;padding-bottom:10px;margin-bottom:20px"&gt;&lt;span style="color:black"&gt;=&lt;/span&gt;&lt;/span&gt;{{roll}}&lt;/div&gt; &nbsp; &nbsp; &nbsp; {{/allprops() title subtitle desc color}} &nbsp; &nbsp; &nbsp; {{#desc}}&lt;div class="sheet-desc"&gt;{{desc}}&lt;/div&gt;{{/desc}} &nbsp; &nbsp; &lt;/div&gt; &nbsp; &lt;/div&gt; &lt;/rolltemplate&gt;
1719612417
GiGs
Pro
Sheet Author
API Scripter
My guess is this is allprops. The list of attribute names is the keys you dont want to show, so you probably need {{#allprops() title subtitle desc color front}} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="sheet-key"&gt;{{key}}&lt;/div&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="sheet-roll"&gt;&lt;span style="font-size: 20px;font-weight:bolder;padding-right:15px;font-color:black;padding-bottom:10px;margin-bottom:20px"&gt;&lt;span style="color:black"&gt;=&lt;/span&gt;&lt;/span&gt;{{roll}}&lt;/div&gt; {{/allprops() title subtitle desc color front}}
1719612748

Edited 1719613601
GiGs
Pro
Sheet Author
API Scripter
This part should be a class: &lt;span style="font-size: 20px;font-weight:bolder;padding-right:15px;font-color:black;padding-bottom:10px;margin-bottom:20px"&gt; Change that to something like &lt;span class="sheet-whatever"&gt; and in your CSS sheet add a declaration for .sheet-rolltemplate-custom2 span.sheet-whatever { font-size: 20px; font-weight:bolder; padding-right:15px; font-color:black; padding-bottom:10px; margin-bottom:20px; }
That seemed to have fixed the issue, thanks a bunch!
1719614423
vÍnce
Pro
Sheet Author
+1