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

Roll Query: Show bonus if not zero

1763052309
Quinn
Pro
Sheet Author
Basically, I'm looking to do something like this: Rolltemplate has "{{attacklabel}}: {{roll}}" Roll Query prompting for attack bonus: "{{attacklabel="Roll+?{Roll Bonus|0}"}} {{roll=1d20+?{Roll Bonus|0}}" So, if the user enters 5, it shows "Roll+5: [[1d20+5]]" Simple stuff, so far, but what I especially want is in the case where the roll bonus is zero, instead of "Roll+0: [[1d20+0]] I'd like it to just say "Roll: [[1d20+0]]". Is that possible?
1763055771
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Are you doing this as a roll template for a custom sheet?
1763059799
Quinn
Pro
Sheet Author
Scott C. said: Are you doing this as a roll template for a custom sheet? Yeah, that's the context.
1763061478
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
then, you'd do this by creating a separate field for the roll query to exist in and pass the roll query in an inline roll. Then just do an inverted check for a rolltotal of zero to determine what to show: {{#roll}} {{#^rollTotal() roll_bonus 0}} <span>{{roll}}+{{roll_bonus}}</span> {{/^rollTotal() roll_bonus 0}} {{#rollTotal() roll_bonus 0}} <span>{{roll}}</span> {{/rollTotal() roll_bonus 0}} {{^roll_bonus}} <!-- this is a duplicate of the rolltotal 0 check for if the roll bonus is not passed --> <span>{{roll}}</span> {{/roll_bonus}} {{/roll}}
1763062755

Edited 1763062804
Quinn
Pro
Sheet Author
Is there a rollTotal() equivalent that can check if a value is above/below a target value? The above code looks like it would display incorrectly if roll_bonus was negative. e: just saw rollGreater() in the documentation. Trying now
1763063235
Quinn
Pro
Sheet Author
Something isn't working as intended. Here's my code: command = `&{template:drive} {{rollname=Basic Attack}} {{attack=[[${roll}+?{Strike Bonus|0}]]}} {{attacklabel=Strike}} {{damage=[[{${force}+?{Damage Boosts|0}*${minorForce},0}kh1+${damageDiceCount}d${damageDiceSides}]]}} {{bonus=?{Strike Bonus}}}` ~~ {{#attack}} <div class="section"> {{#rollGreater() bonus 0}} <span class="label">{{attacklabel}} + {{bonus}}: </span> {{attack}} {{/rollGreater() bonus 0}} {{#rollLess() bonus 0}} <span class="label">{{attacklabel}} {{bonus}}: </span> {{attack}} {{/rollLess() bonus 0}} {{#rollEquals() bonus 0}} <span class="label">{{attacklabel}}: </span> {{attack}} {{/rollEquals() bonus 0}} </div> {{/attack}} When I run this, depending on Strike Bonus: Strike Bonus = 1: "Strike + 1:" Strike Bonus = 0: "Strike + 0" (expected "Strike:") Strike Bonus = -1: " " (expected "Strike -1:") Is this code right?
1763066106

Edited 1763066193
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
rollEquals doesn't exist. you need rollTotal. You also need the rollquery to be in inline roll brackets in order for the logic helpers to be able to read them.
1763068846

Edited 1763068965
Quinn
Pro
Sheet Author
Scott C. said: You also need the rollquery to be in inline roll brackets in order for the logic helpers to be able to read them. I might be misunderstanding this part, but does that mean that there's no way to avoid making it look like this?   The inline roll box around the bonus value looks so clunky. Current code: command = `&{template:drive} {{rollname=Basic Attack}} {{attack=[[${roll}+?{Strike Bonus|0}]]}} {{attacklabel=Strike}} {{damage=[[{${force}+?{Damage Boosts|0}*${minorForce},0}kh1+${damageDiceCount}d${damageDiceSides}]]}} {{bonus=[[?{Strike Bonus}]]}}` ~~ {{#attack}} <div class="section"> {{#^rollTotal() bonus 0}} <span class="label">{{attacklabel}} (Bonus {{bonus}}): </span> {{attack}} {{/^rollTotal() bonus 0}} {{#rollTotal() bonus 0}} <span class="label">{{attacklabel}}: </span> {{attack}} {{/rollTotal() bonus 0}} </div> {{/attack}}
1763070442

Edited 1763070519
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
you can style the inline rolls as you please. Easiest way is to just wrap the bonus in it's own span with a class, and then use css to style the inline roll as you please. Something like: {{#attack}} <div class="section"> {{#^rollTotal() bonus 0}} <span class="label">{{attacklabel}} (Bonus <span class="bonus-span">{{bonus}}</span>): </span> {{attack}} {{/^rollTotal() bonus 0}} {{#rollTotal() bonus 0}} <span class="label">{{attacklabel}}: </span> {{attack}} {{/rollTotal() bonus 0}} </div> {{/attack}} .sheet-rolltemplate-my-template .sheet-bonus-span .inlinerollresult{ background-color: transparent; padding: 0; color: inherit !important; //important so that we override the crit fail styling in the strange event that a user sent a roll in here instead. }
1763080426
Quinn
Pro
Sheet Author
Okay, that works well enough. Thanks for the support!