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

Is it possible to display dice in Roll Templates ?

October 11 (8 years ago)
Tomaxx
Sheet Author
Hi everyone,

My players love to see the dice in the chat, like so:



I plan on creating a roll template for the skill rolls.

Is it at all possible to display the 3 dice above in a roll template, instead of only the number of successes ?
October 11 (8 years ago)
Andrew R.
Pro
Sheet Author
I don't think so. Roll templates require inline rolls. 
October 11 (8 years ago)
Tetsuo
Forum Champion
If you want to use the Power Cards API, you can create roll templates with dice displayed, like so:



Not sure if that's what you're looking for, but its something.
October 11 (8 years ago)
Finderski
Sheet Author
Compendium Curator
You can, but it's tricky and code intensive, and it won't sum the rolls for you. If you're still interested, just say so, and I'll post how I accomplished it when I get home (or at least to my computer). 
October 11 (8 years ago)
Finderski
Sheet Author
Compendium Curator
Ok, I'm at my computer...To get a roll template to show the die results, it requires that you evaluate each roll and then display that die using a font (which means you need to convert each roll into a letter rather than a number. Because you have to evaluate each roll, it gets complicated really fast. So, this works best if you have a finite number of dice. For example, if the number of dice you have to roll each time can be different, you'll need to code the template for each individual die rolled. If the dice can explode, you'll have to figure out how many explosions you want to accommodate, because you'll have to do the explosion manually and send that number of potential rolls to the template up front (because it can't roll dice once you've called the template).

So, given that, you'd want to look at the first page fo the CSS Wizardry forum and find the dice fonts, because you're CSS will need to be set up with that font.  If you want to see how I implemented this for the BASH character sheet, you can check out the github repository, but there's a snippet of the code:
<rolltemplate class="sheet-rolltemplate-stat">
	<h2 class="sheet-caption">{{name}}</h2>
	{{#SoZ}}
		<h3 class='sheet-caption'>Stat of Zero</h3>
		<div class="sheet-result">
			<div class='sheet-BonusPenalty'>
				Stat of Zero:
			</div>
			<div class='sheet-BPTot'>
				{{SoZRoll}}
			</div>
		<!--</div>-->
	{{/SoZ}}
	
	{{^SoZ}}
		<h3 class='sheet-caption'>{{stat}}{{#skill}} {{skill}}{{#specialization}} {{specialization}}{{/specialization}}{{/skill}}</h3>
		<div class="sheet-result">
			<div class='sheet-dieRoll1'>
				{{#rollTotal() r1 1}}
					a<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 1}}
				{{#rollTotal() r1 2}}
					b<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 2}}
				{{#rollTotal() r1 3}}
					c<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 3}}
				{{#rollTotal() r1 4}}
					d<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 4}}
				{{#rollTotal() r1 5}}
					e<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 5}}
				{{#rollTotal() r1 6}}
					f<span class='sheet-trueRoll'>{{r1}}</span>
				{{/rollTotal() r1 6}}
			</div>
			<div class='sheet-dieRoll2'>
				{{#rollTotal() r2 1}}
					a<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 1}}
				{{#rollTotal() r2 2}}
					b<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 2}}
				{{#rollTotal() r2 3}}
					c<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 3}}
				{{#rollTotal() r2 4}}
					d<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 4}}
				{{#rollTotal() r2 5}}
					e<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 5}}
				{{#rollTotal() r2 6}}
					f<span class='sheet-trueRoll'>{{r2}}</span>
				{{/rollTotal() r2 6}}
			</div>
		</div>
	{{/^SoZ}}
</rolltemplate>
and here's a snippet of the CSS:
/* Stat Roll Template */


.sheet-rolltemplate-stat h2.sheet-caption {
	text-align: center;
    color: white; 
    background-color: black;
	border-radius: 15px;
	font-size: 1.125em;
	font-weight: bold;
	margin: 5px;
	margin-bottom: 0px;
}


.sheet-rolltemplate-stat h3.sheet-caption {
	text-align: center;
    color: black; 
    background-color: black;
	border-radius: 15px;
	font-size: 1.125em;
	font-weight: bold;
	font-family: "Patrick Hand";
	margin: 5px;	
	border: 1px solid #a8393f; 
	background-color: #f7dadb;
	margin-bottom: 0px;
}


.sheet-rolltemplate-stat h4 {
	text-align: center;
	margin-bottom: 5px;
}


.sheet-rolltemplate-stat div.sheet-result {
	display: block;
    padding: 5px;
    border-radius: 15px;
    border: solid 1px black;
    text-align: center;
    margin-bottom: 5px;
    background-color: white;
}


.sheet-rolltemplate-stat .sheet-dieRoll1,
.sheet-rolltemplate-stat .sheet-dieRoll2,
.sheet-rolltemplate-stat .sheet-dieRoll3,
.sheet-rolltemplate-stat .sheet-dieRoll4 {
	display: inline-block;
	width: 25%;
    padding: 5px;
    text-align: center;
    font-family: "dicefontd6";
    font-size: 3em;
    z-index: 0;
}


.sheet-rolltemplate-stat .sheet-dieRoll1,
.sheet-rolltemplate-stat .sheet-dieRoll3 {
	border-right: 1px solid black;
}


.sheet-rolltemplate-stat .sheet-dieRoll2,
.sheet-rolltemplate-stat .sheet-dieRoll4 {
	border-left: 1px solid black;
	margin-left: -5px;
}
And here's the output
October 11 (8 years ago)
Tomaxx
Sheet Author
I'm just starting to understand how roll templates work, so this is a bit daunting.
I guess I'll need to spend a little time understanding your code, Findersky.

Thanks everyone for all the replies :)
October 11 (8 years ago)
Finderski
Sheet Author
Compendium Curator
If you have questions, feel free to ask.  Essentially, all I'm doing is sending in different dice rolls individually.  In this case, they always roll 2 dice, but if those two dice match, then other stuff happens. But rather than sending in a 2d6 call, I need to send:
{{r1=[[1d6]]}} {{r2=[[1d6]]}}
Then, the roll template can evaluate r1, and if it matches 1, then I display the letter 'a' using the font "dicefontd6." I have to do that evaluation for every number on the die. So, if you were using d10s, then you'd have to check r1 to see if it equals 1, see if it equals 2, ..., see if it equals 10. The letter would change depending on which die face you want to show. The special function #rollTotal() is what you use to evaluate the die roll.

But that's why I said, it's a lot easier if you know you will only need to ever send 3 dice, or 4 dice. If the number of dice changes depending on the situation, that's fine...you just need to know what the maximum number of dice is, because you'll need to set up the same sort of check for every single possible die, and then make your roll buttons and/or macros in such a way that they always send the correct parament to the roll template (meaning, each dice needs to be sent in as a separate inline roll).
October 11 (8 years ago)
Tomaxx
Sheet Author
In Blue Planet they roll 1, 2, or 3 d10, so worst case its doable.

I have a question: is it possible to make math operations like additions or subtractions inside a rolltemplate?

For example the html I tested:

<button type='roll' value="&{template:test1} {{charname=@{character_name}}} {{attack=[[1d10]]}} {{armor=[[1d4]]}}" name="roll_test1"></button>
and the rolltemplate

<rolltemplate class="sheet-rolltemplate-test1">
    <table>
            <tr><th colspan="2" style="background: #4F2A1B;">{{charname}}</th></tr>
            <tr>
                <td class="tcat">Attack</td>
                <td>{{attack}}</td>
            </tr>
            <tr>
                <td class="tcat">Armor</td>
                <td>{{armor}}</td>
            </tr>
            <tr>
                <td class="tcat">Damage</td>
                <td>[["{{attack}}-{{armor}}"]]</td>
            </tr>
    </table>
</rolltemplate>

This gives this, whatever combination of parentheses I try:



Thanks for all the help!
October 11 (8 years ago)
Lithl
Pro
Sheet Author
API Scripter

Tomaxx said:

In Blue Planet they roll 1, 2, or 3 d10, so worst case its doable.

I have a question: is it possible to make math operations like additions or subtractions inside a rolltemplate?
No, but if the range of possible values is small enough, you could essentially do the same thing as Finderski's dice; "Attack was 5 and armor was 2, so display 3".
October 11 (8 years ago)
Tomaxx
Sheet Author

Brian said:


No, but if the range of possible values is small enough, you could essentially do the same thing as Finderski's dice; "Attack was 5 and armor was 2, so display 3".
Thanks Brian.
If I don't find a workaround I'll have to try this :)


October 11 (8 years ago)
Finderski
Sheet Author
Compendium Curator
Yeah, what Brian said. Assuming it's a modifier you want to apply, something you could do you would be to just pass in the modifier and display that (kind of like what I did with the multiplier in the above example).  So, your call could look something like:
{{r1=[[1d10]]}} {{r2=[[1d10]]}} {{r3=[[1d10]]}} {{modifier=[[2]]}}
Then, you'd evaluate each of the d10s, and display them however you want, have another row (perhaps) and display the modifier.
October 11 (8 years ago)
Tim
Pro
Sheet Author
Compendium Curator
Incidentally, is there a thread in the Suggestions & Ideas forum for more flexibility in displaying in-line dice in roll templates? It comes up all the time, and it's a frustrating limitation. 
October 11 (8 years ago)
It's doable in PowerCards if you want to include that script as a requirement for the character sheet.
October 12 (8 years ago)
Tomaxx
Sheet Author

SkyCaptainXIII said:

It's doable in PowerCards if you want to include that script as a requirement for the character sheet.

Where can I find the PowerCards script? It doesn't appear in the API:Script index or in the GitHub api repository (either that or I am still too asleep to see it!)
October 12 (8 years ago)
Tetsuo
Forum Champion
You can find it Here
October 12 (8 years ago)
Tomaxx
Sheet Author

Franky H. said:

You can find it Here

Thanks Franky. I missed the link to the repository on that post.