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

[HELP] with Roll Templates

1436906292
Finderski
Pro
Sheet Author
Compendium Curator
In my character sheet I have really two different Roll Templates (currently), a Skills Roll Template, and a Damage Roll Template. Really, though there are 4 different ones, because I have two different backgrounds (a plain background and an image background) for each of the two different roll templates. It really bothers me that I have to double the amount of code for one little thing like a background image. Here's the question: Is there a way to toggle the image on/off in a roll template without having to have a full set of code for it? What I mean by that is: I'd like to have the code for skills only once, but still allow people to use or not use the background image as they see fit. How can I do this?
1436927439
Lithl
Pro
Sheet Author
API Scripter
You could have a toggle attribute in the template, and wrap {{#background}} around a containing div, then put the background on that. Something like: {{#background}} <div class="my-rolltemplate-background"> {{/background}} This is my template. It is {{awesome}}. {{#background}} </div> {{/background}}
1438007019
Finderski
Pro
Sheet Author
Compendium Curator
Worked like a charm! Thanks, Brian.  For those interested in how I got Brian's suggestion to work...here's the code: <rolltemplate class="sheet-rolltemplate-combined"> <h2 class="sheet-caption">{{header}}</h2> {{#rollTotal() background 0}} <!--Solid--> <div class="sheet-noBG"> {{/rollTotal() background 0}} {{#rollTotal() background 1}} <!--Ace of Spades Background--> <div class="sheet-AceSpades">  {{/rollTotal() background 1}} {{#rollTotal() background 2}} <!--Ace of Clubs Background--> <div class="sheet-AceClubs"> {{/rollTotal() background 2}} This is my template. It is {{awesome}}. {{#background}} </div> {{/background}} </rolltemplate> Then to call it you do something like: &{template:combined} {{header=@{character_name} w/@{repeating_meleeweapons_0_WeaponType}}} {{background=[[2d1]]}}  Of course, to get 0, I just roll 0d1, or 1d1 to get a value of 1.  But that way, I can choose between three different backgrounds.
1438008669
Wes
Sheet Author
Hey G V. I don't believe you need to actually have rolls for the rollTotal to work, I'm on my phone but I will post some examples later today when I get home.
1438036986
Wes
Sheet Author
Sorry for the Delay I was struck by a Nap. The #rollTotal() just looks at the number enclosed with in the  [[ ]] inline brackets so you can actually use integers instead of dice rolls. So in your example above you can simply call the background with: {{background=[[0]]}} OR {{background=[[1]]}} OR {{background=[[2]]}} without having to actually specify a die size to roll. It's probably not that big of a deal but for me its a bit cleaner than using the 2d1. I have actually used the exact same method as you have above for emulating a rollable table in the Kobolds Ate My Baby character sheet.
1438037468
Finderski
Pro
Sheet Author
Compendium Curator
Wes, thanks for the tip.  After I saw your first post I experimented with exactly what you use above, so I'd figured that out as well. :) But it was your first post that gave me the idea to try it that way.