CrystalBall Lite uses templates to format a roll's results
CrystalBall Lite's dice roller performs very powerful rolls. As the rolls increase in complexity, the output of the roll may become long and hard to undestand. Templates make the output completely customizable allowing for quick understanding of the roll's results. Templates can be used to show the pertinent parts of a roll and for combining the results of a roll in an easy-to-read format.
Basic Usage
The following describes the basic usage of templates. Sections following this one will give more details about Named Templates, Optional Sections, and Text Formatting. This section focuses on the basic usage and principle of a template.
A template replaces a roll's text output. This way, the roll can be displayed however you want for easy reading yet still perform complex rolling.
- Template Format: :template=The result of the roll is [1d20, number]:
- If the result of 1d20 is 20 then this template would show the text The result of the roll is 20
-
The [ ] section defines a roll and how to show the roll. The roll can be any valid roll. One powerful way to use a template is to assign a roll's results to a variable outside of the template and then reference the variable several times as needed in a template. For Example, note the following template:
:template=[$attack$, number] was rolled for a [$attack$, string] attack:$attack$=1d20"Flaming Broad Sword"
If the 1d20 rolled a 10, then the template would show 10 was rolled for a Flaming Broad Sword. Notice the double use of the $attack$ variable in the template and how $attack$ was rolled once oustide of the template. -
The formatting option can be one of the three following values:
- Roll: This shows the roll in the standard full format
- String: This shows just the string portion of a roll. If the roll is 1d20 "Luck Check" then the template would just show Luck Check
- Number: This shows just the final numeric result of the roll. If a roll is 1d20 "Luck Check" and 1d20 rolled 10, then the template would just show the numeric result of 10 in the template.
-
To have text break on to a new line put <ENDOFLINE> in to the template. For example, :template=This is line #1<ENDOFLINE>This is line #2:
This is line #1 would appear on the first line and This is line #2 will appear on the line below it. -
The template syntax allows just the desired results of the roll to be shown and avoid having to view the full roll information.
For example, note the following template:
:template=Surprise round attack "[$attack$, string]" rolled a [$attack$, number]:$attack$ = 1d20+6"broad sword of fire burst"
If the d20 rolled a 10, the output would show Surprise round attack "broad sword of fire burst" rolled a 16.
Text Formatting
Text can also be formatted with colors, bold, italic, text size, and font. This is done using tags around the text to be formatted.
- Bold uses <b> </b> tags For exmaple, <b>'The Text'</b> ('The Text' will appear bolded)
- Italic uses <i> </i> tags For example, <i>'The Text'</i> ('The Text' will appear in italics)
- Color uses <font color=red> </font> tags For example, <font color=yellow>'The Text'</font> ('The Text' will appear yellow)
- Color can be defined by using Red Green Blue (RGB) hexadecimal values <font color=#00FF00>Green Text</font> This shows the "Green Text" comment in green. The first two numbers are how much red, second two are how much green, and the last two are how much blue. This allows custom creation of most any color desired.
-
Color can also use <color=red> </color> tags For example, <color=yellow>'The Text'</color> ('The Text' will appear yellow)
CrystalBall Lite provides standard colors, but a color can also be described using Red, Green, and Blue parts in the form of #RRGGBB. Each two character part is a two character hexidecimal part. #FF0000 is solid red, #00FF00 is solid green, #0000FF is solid blue, and #08D214 is a combination of all three colors.
To see a visual chart of color codes, please search Google for "html color chart".
The much more easier method is to use a color from the following list of CrystalBall Lite's known colors. (If you'd like a color name added, please post on the forums at the CrystalBallSoft Messageboards).- aqua
- black
- blue
- darkblue
- green
- lavendar
- maroon
- olive
- orange
- pink
- purple
- red
- white
- yellow
- Size uses <font size=20> </font> tags (For example, <font size=10>'The Text'</font> 'The Text' will appear with a font size of 10)
- Font uses <font face='arial'> </font> tags (For example, <font face="helvetica">'The Text'</font> 'The Text' will appear in the helvetica font)
- Font attributes can be used in combination (For example, <font face="helvetica" color=green size= 20>'The Text'</font> 'The Text' will appear in the helvetica font, be green in color, and have a size of 20)
-
Tags can overlap each other as needed (For example, <b>First Section <i>Second Section</b> Third Section</i> => First Section appears bold, Second Section appears bold and italic, and Third Section appears italic.)
Example:
- "<b>ATTACK!</b> The result of the '<i>ATTACK!</i> Broad Sword' attack is <font color=red>20</font>"(Shows: ATTACK! The result of the 'ATTACK! Broad Sword' attack is 16 )
Optional Sections
Optional Sections are used to show information based on a condition. This way, only things that need to be shown are shown.
- :template={1d20 >> 10,The result was greater than 10,The result was less than 10}: The result was greater than 10 will only show if the result of 1d20 was greater than 10 and The result was less than 10 will only show if the result of 1d20 was less than 10
-
:template=Attack roll = [$attack$, number] for [$damage$, number] damage {$flaiming_damage$ <> 0, plus 'Flaming Strike' damage = [$flaming damage$,number]}:$attack$=1d20;$damage$=1d8+4;if $attack$ == 20 then $flaming damage$=2d6 end This is a complicated roll, so it is broken down in to its parts. First described are the three rolls and then the template will be dissected.
- First Roll: $attack$=1d20 This sets the result of 1d20 + 6 in to an 'attack' variable for use later.
- Second Roll: $damage$=1d8+4 This sets the result of 1d8 + 4 in to a 'damage' variable for use later.
- Third Roll: if $attack$ == 20 then $flaming damage$=2d6 end If the 'attack' was a 20 then it sets the 'flaming damage' to the result of 2d6. If the result is not 20, then the 'flaming damage' variable is not set.
- Template Result - Case 1 : 10 is rolled for the d20 and 8 is rolled for the damage. Since 10 does not equal 20 then the 'flaming damage' variable is not set and the optional section does not show. The template would show Attack roll = 10 for 8 damage.
- Template Result - Case 2: 20 is rolled for the d20 and 8 is rolled for the damage. Since 20 equals 20, then the 'flaming damage' variable gets set to the result of 2d6 which for this case will be 7. The template would show Attack roll = 20 for 8 damage plus 'Flaming Strike' damage = 8.
-
The second part of the optional section is treated as a template, so it can contain Optional Sections and Roll Sections. (For example, {1d20 >> 10, [1d20, number]} If the first 1d20 resulted in a roll greater than 10, then another 1d20 is rolled and its result is showed as a number. If the original 1d20 was less than or equal to 10, then nothing is displayed for this section. Optional Sections are a quick and more powerful way to use conditionals rather than putting the conditional logic in the section
- :template=[if 1d20 >> 10 then "Holy Smokes!" else "Tarnation!" end, string]:
- Is the same as
- :template={1d20 >> 10,Holy Smokes!,Tarnation!}:
- both are not the same as
- if 1d20 >> 10 then "Holy Smokes!" else "Tarnation!" end (This will show the full results of the 1d20 and conditional parts instead of just the resulting texts)
- :template=[if 1d20 >> 10 then "Holy Smokes!" else "Tarnation!" end, string]:
- *NOTE* To have commas appear in text, the first example of using a [ ] section can be used.
- The roll part of the Optional Section does not get displayed. To have the roll part displayed set a variable outside of the template equal to the roll and check the variable inside the template (instead of putting the roll in the template) and have the template display the variable.
Named Templates
Templates may be used for any roll and can be nested in rolls called from other rolls (for example, a button rolling on a table). Some templates may be common between several rolls. Instead of having to copy the template between the multiple locations, a template can be given a name. The name is then used when putting the template in the roll. This also allows the template to be changed in one place and to effect all the rolls that use it.
- Templates are associated with a name in the Templates subtable of the current diceset. To view the templates for a dice set, go to the 'Dice Sets' menu. Select the desired dice set. Click the 'Edit Variables' button. In the newly opened Table Editor, select the 'Templates' subtable. This is where templates can be managed.
- The Templates subtable has two columns.
- The 'Template Name' column is where the name of the template is put.
- The 'Template Value' column is where the actual template is put. Don't use the full template format here. Put just the part that would come after ':template='. So, instead of putting :template=Attack roll = [1d20, number]: in the 'Value' column, just put Attack Roll = [1d20, number].
- When referring to the named template in a roll, put the name of the template directly after :template=. For exmaple, if the name of the template in the 'Template' column of the DefaultTemplates table is My Template then the template could be used like :template=My Template:
- Generator Table Templates Generator tables can have a sub table for templates which are used just for that generator table. This way, generator tables can be portable, since they have all their required information stored in themselves. These templates stored in the Generator Tables are only usable by the generator table's rolls themselves, not by outside rolls. To use a generator table's templates, the templates need to be copied from the generator table's templates subtable to your DefaultTemplates table.