Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Roll Templates"

From Roll20 Wiki

Jump to: navigation, search
(Created page with "Roll Templates are a special facet of the Character Sheets system which provide additional layout and styling options for the dispay of roll results. ==Using Roll Templates==...")
 
m
(100 intermediate revisions by 26 users not shown)
Line 1: Line 1:
Roll Templates are a special facet of the Character Sheets system which provide additional layout and styling options for the dispay of roll results.
+
Roll Templates are a special facet of the [[Character Sheets]] system which provide additional layout and styling options for the display of roll results.
 
+
[[File:Roll template default example2.JPG|right|thumb|350px|The output of a '''default template''' used in {{Text Chat}}]]
 
==Using Roll Templates==
 
==Using Roll Templates==
 +
 +
If you're using a Character Sheet, there's a really good chance you'll use a Roll Template just by clicking the roll button on the sheet, or by calling a sheet roll in a macro or ability. '''You don't have to do anything extra to do this, it's already set up for you in advance by the sheet author.'''
 +
 +
If you're interested in using Roll Templates in your own custom macros or creating your own custom templates, read on further.
  
 
Using a roll template is very easy. Just include a special flag in your chat message which tells Roll20 that you want to use a Roll Template, and then provide all of the data that you want to include. Here's an example that uses the "default" template (which all games have access to, regardless of the game system or character sheet you are using):
 
Using a roll template is very easy. Just include a special flag in your chat message which tells Roll20 that you want to use a Roll Template, and then provide all of the data that you want to include. Here's an example that uses the "default" template (which all games have access to, regardless of the game system or character sheet you are using):
  
&{template:default} {{rollname=Test Attack}} {{attack=[[1d20]]}} {{damage=[[2d6]]}}
+
<pre style="overflow:hidden;white-space:pre-wrap">
 +
&{template:default} {{name=Test Attack}} {{attack=[[1d20]]}} {{damage=[[2d6]]}}
 +
</pre>
  
The &{template:<template_name>} is the part that tells the system to use a Roll Template, and specifies the name of the template you want to use. Then you just provide all the data for the template in the format {{<propertyname>= <value>}}. The "propertyname" that you should use depends on the template -- the Character Sheet documentation should let you know what's available, and we've provided documentation on all of the built-in templates below. "Value" can be either text or an inline roll, including macros, abilities, etc. Note that if you use a macro or ability, it must be an inline roll, not a "/roll" command.
+
[[File:Roll template default example.JPG||right]]
 +
The <code>&{template:<template_name>}</code> is the part that tells the system to use a Roll Template, and specifies the name of the template you want to use. Then you just provide all the data for the template in the format <code>{{<propertyname>= <value>}}</code>. The "propertyname" that you should use depends on the template -- the Character Sheet documentation should let you know what's available, and we've provided documentation on all of the built-in templates below. "Value" can be either text or an inline roll, including macros, abilities, etc. Note that if you use a macro or ability, it must be an inline roll, not a <code>/roll</code> command.
  
Here's an example that uses a "%{Character|attack}" ability:
+
{{orange| Macros for roll templates are sensitive to leading spaces, so '''<code><nowiki>{{name=Dexterity}}</nowiki></code>''' will work, but  '''<code><nowiki>{{ name=Dexterity}}</nowiki></code>''' won't. }}
  
&{template:default} {{rollname=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}
+
Here's an example that uses a <code>%{Character|attack}</code> ability:
 +
 
 +
<pre style="overflow:hidden;white-space:pre-wrap">
 +
&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}
 +
</pre>
 +
 
 +
====When Can I Use Roll Templates?====
 +
 
 +
You can use a Roll Template in general messages (without a command like <code>/desc</code> or <code>/emote</code>) and whispers. You can't use roll templates with the <code>/roll</code> command; instead, Roll Templates are meant to be used with inline rolls. As long as they use inline rolls, you can use Roll Templates with macros, Character Abilities, and sheet authors can use them inside of their Roll Buttons on sheets.
  
 
==Built-In Roll Templates==
 
==Built-In Roll Templates==
  
The following roll templates are built-in to Roll20 and can be used in any game.
+
The following roll templates are built-in to Roll20 and can be used in any game. You don't have to even have a character sheet template selected for your game to use it.
  
'''Default'''
+
====Default====
  
To use the default template, use "&{template:default}".
+
To use the default template, you first call <code>&{template:default}</code>, the (optionally) define what will be shown in the header in a <code><nowiki>{{name= }}</nowiki></code>-section, after which you can create any number of "rows" by creating more <code>{{ }}</code>-sections.
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 25: Line 40:
 
! Property !! Expected Value
 
! Property !! Expected Value
 
|-
 
|-
| rollname || The name of the roll, shown in the header of the roll listing
+
| name || The name of the roll, shown in the header of the roll listing. (''If not used in a roll, the header will appear at the top of the roll template as a purple bar with no text.'')
 
|-
 
|-
| attack || The attack roll
 
|-
 
| attackadvantage || For systems that have advantage (such as 5E), the second attack roll. Will be shown next to the first attack roll.
 
 
|}
 
|}
 +
 +
'''The default template is special''', and will list out whatever argument you give it in a table. It will put in the middle of the purple header anything you define in the <code><nowiki>{{name= }}</nowiki></code> section, and then with every subsequent <code>{{ }}</code> segment, it will alternate with white & gray background.
 +
 +
If a <code>=</code> is used in the <code>{{ }}</code> rows, the roll template will align the <code>=</code> in the middle, and all rows will have the <code>=</code> in the same spot. If any row have lots of more text/content on either side of the <code>=</code>, it will be pressed to the side of the template for all rolls.
 +
 +
So for example, you could do the following:
 +
 +
<pre style="overflow:hidden;white-space:pre-wrap">
 +
&{template:default} {{name=Test Attack}} {{attack=[[1d20]]}} {{note= This is some note content}} {{Saving Throw= vs Will}}
 +
</pre>
 +
[[File:Roll template default example2.JPG]]
 +
<br />
 +
 +
Notice that the content of the roll template is pressed to the left side, due the text segment on the '''Note'''-row. If that segment is removed, the content of the remaining rows will be closer to the center.
 +
 +
<big>[https://jsfiddle.net/8w3qm3zL/41/ Here] is a fairly exact example of the default template with it's dependent CSS classes.</big>
  
 
==Creating a Roll Template==
 
==Creating a Roll Template==
 +
''Main Page:'' '''[[Building Character Sheets/Roll_Templates]]'''
  
If you are a '''Sheet Author''', you can include as many roll templates as you want in your Character Sheet HTML and CSS. We'll let you know how below.  
+
You can create & use custom Roll Templates by [[Building Character Sheets|Editing/Building Character Sheets]], as they are a part of the Character Sheet's code.
  
If you are a '''Mentor''', you can create your own Roll Templates if you are using the "Custom" character sheet option with your game. Follow the instructions below.
+
The main page details what parts & features goes into creating a roll template, along with showing the code for a number of existing Roll Templates
  
'''Defining the Layout of the Roll Template'''
+
= See Also =
 +
* '''[[Complete Guide to Macros & Rolls‎]]'''
 +
** {{Text Chat}} - where the roll results appear, & info on the common chat commands
 +
** [[Dice Reference]] - Comprehensive list of how the Roll20 dice-rolling syntax works, and list the features available
 +
** [[Macros]] - How to create macros, and other info on how the Roll20 <span style="font-family:Pictos;">q</span>Text Chat works, like referencing stats on character sheets, roll queries, nesting macros & initiative
 +
*** [[Reusing_Rolls#Rolltemplate_Helper_functions|Reusing Rolls in Roll Templates]]
 +
** [[Roll Templates]] - a method of formatting roll results in the chat, with some extra functions
 +
** [[API]]''(Pro Only)'' - API commands can be used in the <span style="font-family:Pictos;">q</span>Text Chat
 +
* [[BCS|Building Character Sheets]]
 +
** [[Building Character Sheets/Roll Templates|Creating Roll Templates]]
 +
** [[Sheet Author Tips]] More advanced tips for creating/maintaining sheets, workflow, & useful tools
 +
** [[Custom Sheet Sandbox|Sheet Sandbox]] – the better editor to use when you code your character sheets
 +
* [https://roll20.zendesk.com/hc/en-us/articles/360037257334-How-to-Make-Roll-Templates Roll20 Help Center version of this page] - Almost always outdated/lacking compared to any pages on sheet development on the wiki
 +
<br>
 +
<br>
  
The first step in creating a Roll Template is defining the layout, including what properties you are going to make available to be filled in by player. Roll Templates are just HTML, and you have access to all the same HTML as any other part of a Character Sheet (including <div> and <table>). Here's an example of the layout of a Roll Table:
+
[[Category:Docs]]
<pre>
+
[[Category:Macros]]
<table>
+
<tr><th>{{rollname}}</th></tr>
+
<tr><td><span class="tcat">Attack: </span>{{attack}} | {{attackadvantage}} vs AC</td></tr>
+
{{#damage}}
+
<tr>
+
<td><span class="tcat">Damage: </span>{{damage}} <span class="tcat">Crit: </span>{{dmgcrit}}</td>
+
</tr>
+
<tr>
+
<td><span class="tcat">Type: </span>{{dmgtype}}</td>
+
</tr>
+
{{/damage}}
+
<tr>
+
<td><span class="tcat">Effect: </span>{{atteffect}}</td>
+
</tr>
+
</table>
+
</pre>
+

Revision as of 12:59, 7 January 2021

Roll Templates are a special facet of the Character Sheets system which provide additional layout and styling options for the display of roll results.

The output of a default template used in q Text Chat

Contents

Using Roll Templates

If you're using a Character Sheet, there's a really good chance you'll use a Roll Template just by clicking the roll button on the sheet, or by calling a sheet roll in a macro or ability. You don't have to do anything extra to do this, it's already set up for you in advance by the sheet author.

If you're interested in using Roll Templates in your own custom macros or creating your own custom templates, read on further.

Using a roll template is very easy. Just include a special flag in your chat message which tells Roll20 that you want to use a Roll Template, and then provide all of the data that you want to include. Here's an example that uses the "default" template (which all games have access to, regardless of the game system or character sheet you are using):

&{template:default} {{name=Test Attack}} {{attack=[[1d20]]}} {{damage=[[2d6]]}}
Roll template default example.JPG

The &{template:<template_name>} is the part that tells the system to use a Roll Template, and specifies the name of the template you want to use. Then you just provide all the data for the template in the format {{<propertyname>= <value>}}. The "propertyname" that you should use depends on the template -- the Character Sheet documentation should let you know what's available, and we've provided documentation on all of the built-in templates below. "Value" can be either text or an inline roll, including macros, abilities, etc. Note that if you use a macro or ability, it must be an inline roll, not a /roll command.


Here's an example that uses a %{Character|attack} ability:

&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}

When Can I Use Roll Templates?

You can use a Roll Template in general messages (without a command like /desc or /emote) and whispers. You can't use roll templates with the /roll command; instead, Roll Templates are meant to be used with inline rolls. As long as they use inline rolls, you can use Roll Templates with macros, Character Abilities, and sheet authors can use them inside of their Roll Buttons on sheets.

Built-In Roll Templates

The following roll templates are built-in to Roll20 and can be used in any game. You don't have to even have a character sheet template selected for your game to use it.

Default

To use the default template, you first call &{template:default}, the (optionally) define what will be shown in the header in a {{name= }}-section, after which you can create any number of "rows" by creating more {{ }}-sections.

Property Expected Value
name The name of the roll, shown in the header of the roll listing. (If not used in a roll, the header will appear at the top of the roll template as a purple bar with no text.)

The default template is special, and will list out whatever argument you give it in a table. It will put in the middle of the purple header anything you define in the {{name= }} section, and then with every subsequent {{ }} segment, it will alternate with white & gray background.

If a = is used in the {{ }} rows, the roll template will align the = in the middle, and all rows will have the = in the same spot. If any row have lots of more text/content on either side of the =, it will be pressed to the side of the template for all rolls.

So for example, you could do the following:

&{template:default} {{name=Test Attack}} {{attack=[[1d20]]}} {{note= This is some note content}} {{Saving Throw= vs Will}}

Roll template default example2.JPG

Notice that the content of the roll template is pressed to the left side, due the text segment on the Note-row. If that segment is removed, the content of the remaining rows will be closer to the center.

Here is a fairly exact example of the default template with it's dependent CSS classes.

Creating a Roll Template

Main Page: Building Character Sheets/Roll_Templates

You can create & use custom Roll Templates by Editing/Building Character Sheets, as they are a part of the Character Sheet's code.

The main page details what parts & features goes into creating a roll template, along with showing the code for a number of existing Roll Templates

See Also