Using Story Templates to Create Random Stories
Introduction
A Story template is a special kind of record that can generate new story records from rollable tables either in the same campaign or from another module. They can be used for any number of purposes to generate descriptions of places, npcs, items or indeed anything pertinent to the campaign.
To access the list of Templates in the campaign click on the Templates button in the Story records campaign list. To create a new Story Template, click on the green ‘+’ at the bottom of the window.
To create a story from a Story Template, click on the ‘Generate’ button at the bottom of the Template window. The Template will use special text information embedded into the Template to look up information from the linked tables to create the story. A new story entry will be added to your current campaign, and the story record will be displayed.
A Very Simple Example
To illustrate the potential of this feature let us walk through a very simple example. We'll create a Template which generates a name for a general store. Before we get to creating the Template, we’ll need to create a couple of rollable tables. These tables will be used by the Template to randomly select a first and second part of the shop’s name.
Now that we have the resources we need, we can get on with creating our Story Template. Create a new Template, give it a name and then type in as follows:
[First Part]] [Second Part]
This store is called <First Part> <Second Part>
And then click on the ‘Generate’ button. You should have something like this:
When we click on the Generate button, Fantasy Grounds VTT uses the information in the Template to generate the information we want. The text inside the square brackets [] is interpreted as ‘roll on the table with the same name as the text inside the brackets and replace the text with the result of that roll’. Thus the [First Part] rolled on the First Part table and got a result of 3 and substituted ‘Premium’ for the text inside the square brackets; and it then did the same thing for [Second Part]. The result of these two rolls is remembered by FGVTT and by using the same text inside angled brackets <> can be recalled and used in a sentence as illustrated in the graphic.
Adding More Stuff
We can make this template do a lot more than this, and to illustrate that let’s create a bunch more tables:
Using these tables, we can create a template something like this:
Notice that this time we’ve enclosed the ‘story’ part of the template in a speech bubble (by selecting the text and pressing CTRL+3). When we generate the story from this template, we’ll have a ready-made description that we can drop into chat for our players to see. Notice also that we can have all kinds of formatted text in the template which will follow through into the story we generate from it.
Further Expansion
We can expand this template further, perhaps giving the shop an inventory of items that it might sell. For this we’ll need some more tables. These tables have been drawn up by adding the items to each table row from either the Player’s Handbook, or the Dungeon Master’s Guide. When the story is generated, these links will be added to the story so that they can easily be added from there by dragging into a treasure parcel, character’s inventory, or shared via chat, or a character’s portrait. Notice that in the case of the Armor Table we have a chance that the shop will have a special armor available. The Armor table is linked to the Special Armor table and if there is a roll of 5 or 6 then a roll will be made on the Special Armor table. There’s then a 1 in 5 chance that a magical set of armor will be for sale. See the article on Tables for more information on linking tables.
Link: Using Tables to Create Random Results
So, let’s add the inventory to our Template.
You’ll notice that in some cases we have some numbers in square brackets immediately preceding the call to the table. In the case of General Gear, for example, we are asking the Template to roll on the table 4 times (designated by using [4x]) and for Magic Items we are asking to roll once or twice (designated by [1d2x]). We can use any dice expression to roll a random number of times on a table, or we can call the table just once or a set number of times. The expression must be enclosed in square brackets [] and must contain a multiplication sign ‘x’. In the case of the Armor table, we are just calling the table twice, once on each row; we could have equally used [2x] to do the same thing.
In addition to the table rolls we can also generate numbers within a template. The last section of the Template shows how we could randomly calculate how much gold the merchant has available to buy unwanted items from the players, the maximum price he will pay for goods they want to sell him, and the price percentage he charges over the nominal cost of the goods in the Player’s Handbook.
This is one possible result of this template:
More Complex Examples
Multi-Column Tables
So far, we have only used tables with a single column. So, let’s now have a look at the interaction with multi-column tables and templates. When FGVTT rolls on a multi-column table it returns the result from all the columns on that table row. To use this result, we need to specify in the Template which column we want to use from the table. We do this using the pipe “|” character. If we want to include the result of this roll in a sentence, then we need to use the hash “#” character in place of the angle brackets. In the template below we are making two rolls on the same table but taking the color result from the first column and the clothing article from the second column.
All Results from a Multi-Column Table
If, when rolling on a multi-column table, we don’t specify a column then FGVTT returns all the results for each column on that row. We can capture this information in a template and store all the values returned for later use inside the template.
In the simple example above, we have a table with two rows that produces the sex and pronouns, both capitalized and in lower case, of an NPC. The template will recall all the information on whichever row is rolled and keep it inside the template so that it can be used later in the template. This allows us to construct sentences like in the example where we need consistency in the description, as well as being able to start and insert words into a sentence with the correct capitalization.
Suppressing Output
We can suppress the first part of the template above if we don’t want to have the results displayed in the output by inserting a query into the table call thus [?Gender]. This will not print out the list of outputs below the Roll on the Table section, but it will still retain all the results of the roll as we can see below.
The query can be used to suppress virtually every output if you do not want that result to be displayed in your generated story.
Custom Naming
Within a template you can create a custom name for something which you can then use in a different part of the template. A simple example of this is shown below where we are assigning colors to various things that we later want to recall in a sentence. To create the name, we use colons to denote the table we want to roll on followed by the name we want to store the table roll value in. Hence [:Color:Dress] will roll on the table called Color and store whatever result we get from that roll in the word ‘Dress’. We can then later recall that in a sentence by enclosing the word Dress in angled brackets <Dress>.
Internal Rolling
We can set up a template in such a way that it can roll on a table name that it creates itself. For example, suppose we have tables for gender and race, and we wanted to generate a name for a randomly selected race and gender. By getting the template to use a name we generate within the template itself we can drastically reduce the number of tables we need, and we can also use the results again elsewhere within the template. Let’s suppose we wanted to create the first and last names of a randomly generated Bartender with randomly generated race and gender. The syntax we’ll use is as follows: [:[Race] [Gender] Name:Bartender]. This is going to randomly select a race and gender and then it’s going to roll on a table using that race and gender appended by ‘Name’ and then store that result in the variable ‘Bartender’. We can then recall the Bartender's full name using <Bartender> and we can still recall the race, gender and the first and last name separately wherever else we want to in the text.
Note that there are other tables used here which aren’t shown in the graphic.
Internal Referencing
Internal referencing is when we use a previous roll to make a roll on another table created inside the template like the above. In the template below we are calling a table (Race) within a sentence and then using that roll in the following sentence to roll on a table with the race that we rolled to create a name for a character. You’ll notice in the first sentence we have enclosed the indefinite article ‘a’ in brackets. Doing this intelligently changes the ‘a’ to an ‘an’ if the race rolled starts with a vowel. As you can see in our Race table, we could roll Elf or Dwarf, so we want the sentence to read properly depending on what is rolled. Using (a) means that we’ll get the correct indefinite article if we roll Elf.
Internal Column Referencing
This is very similar to the above except we are using column referencing. We’re rolling on a multi-column table and then using the results that we got to both create a name for the woman and correctly construct the sentence based on the race that was rolled. In the template below we are ‘creating’ the name of the table we want to roll on to generate the name of the character using [#Race|1# Name]. This translates to ‘Dwarf Name’ in this example, making a call on the table with that name which in turn calls further tables to create the first and last name of the character.
Cross Template Referencing
It is also possible to reference the results from one template in another separate template. To do that we need to use the curly brackets {} to fetch results, and to set up names etc. In the example below Template One is tasked with making a roll on a table called Geography which will generate some details about a village and will store that roll in a place we have called ‘Village’. The second template will then use the generated result to construct a sentence about that settlement. Notice that in the Geography table the Inhabitants column has the first letter of the race in parenthesis. By doing that we are telling the template to look at whether this word starts a sentence and if it does the first letter should be capitalised; otherwise, the first letter should be lower case. Notice also that we can recall information generated in the titles of templates and in headings within the template.
Let’s now generate some results.
Date Formatting
You can recall dates within a Template either from the system (your computer) or from a loaded and set up calendar within your campaign. The format for this is [Date:Format] or [FGDate:Format]. Format can be any of the following:
yyyy = Full year (e.g. 2025)
yy = Partial year (e.g. 25)
month = name of the month
mm = month as a number
mmm = Shortened month (e.g. Sep - Note: this only works with Gregorian Calendar)
day = Name of the day
dd = Day as a number
ddd = day appended by suffix (e.g. 1st, 3nd, 3rd, etc)
epoch = (for example AD, BC etc)
oldschool = for example Friday, the 2nd of November, in the year of our Lord Nineteen Hundred and Eighty-Four (this does not work with FGDate format).
You can use almost any character as separators including a space. However, avoid more esoteric characters such as em-dashes and punctuation marks. Generally it’s safe to use slashes, hyphens, and spaces.
Technical Stuff
Bracketed Text []
The story generation feature will attempt to resolve bracketed text in the following order:
Evaluate dice strings
Only if bracketed text is a valid dice string
Ex:
[1d4+10]
Evaluate table multipliers
Only if bracketed text is a valid dice string ending with a 'x'
Ex:
[1d6x]
Evaluate table lookups
Only if bracketed text is the name of a table in the current campaign
The bracketed text may be following by a pipe symbol '|' and a number to denote a single column lookup on a multi-column table
Ex:
[250 gp Art Objects], [Slashing Criticals|2]If the table contains multiple columns, then each lookup result will be combined for the final result.
If preceded by a table multiplier tag, multiple table lookups will be done, and combined.
Any table non-link result text will be saved for tagged text replacement (see below).
Do nothing, but remove brackets.
When each bracketed text entry is evaluated, the results are used to replace the bracketed text.
Tagged Text <>
The story generation feature will attempt to replace any tagged text with the results generated from a table with a name matching the tagged text. (see bracketed text table lookups above) If the tagged text refers to a table that does not exist, or which was not used in the story template, it will be ignored.
Even More Complex
The integration of Story Template Pro has furthered templates to include a few new functions. These functions will be laid out below, but lessons learned earlier will be needed to take full advantage of this new functionality.
You can see a breakdown of these elements as well from the code’s creator here:
Column Referencing #a|3#
Reference single columns of previously rolled table results. These results are stored when rolled and can be referenced multiple times without re-rolling the table that produced said result.
Table ‘a’:col1: Gnomecol2: femalecol3: Gribblescol4: she
Template:
The silhouette of a #a|1# appeared in the tavern doorway, ringed in the moonlight from outside. #a|4# strides in and takes a seat next to you.
The name’s #a|3#” #a|4# says as #a|4# motions for the bartender.
Output:
The silhouette of a Gnome appeared in the tavern doorway, ringed in the moonlight from outside. She strides in and takes a seat next to you. “The name’s Gribbles” she says as she motions for the bartender.
Callout Custom Naming [:a:b]
Create custom reference names for table results you generate. This helps further help reference results of previous tables, by placing them in a variable like name that can be referenced. This name then can be called upon when the template is generated and helps organize output within the template.
[:Color:eyes] > Blue[:Color:teeth] > Yellow<eyes> > Blue
Rolled on the NPC table four times and stored results within each new name.
[:NPC:Spy][:NPC:Bartender][:NPC:Jester][:NPC:Vagrant][:?NPC:Badguy]#Badguy|2# > Jimmy
Callout Internal Rolling [:[a] [b]:c]
Roll on tables within tables. This sets up a roll on nested tables and keeps the contents of that roll to be referenced later in the generated story.
[:[race] [gender] name:Bartender]
Now you can not only reference each column of the result individually with #Bartender|1# or #Bartender|2#, but <Bartender> also works to deliver [race] [gender].
Callout Internal Referencing [<a>]
Use table references to determine which tables to roll on. You can further use the reference to further use it to roll on tables with the same name or nested tables.
You stumble upon a [race] settlement.The mayor, an old <race> named [<race> name] greets you.
If the race table originally rolled “Dwarf”, then it will get inserted into the Callout Internal Reference and the resulting [Dwarf name] table will be rolled upon.
Callout Internal Column Referencing [#a|3#]
Use internal column references to determine which table to roll on.
[#NPC|7# name] might roll on [Elf name], if the 7th column of the NPC table was race.
[<race> #NPC|2# name] might roll on [Human Female name] if you wish to further use a combination of the results.
Hidden rolls (using “?”)
Hide rolled table results in the generated story. This will roll on said table, but won’t show the results within the story template. This result however can be referenced and keep output text cleaner.
Works with many callouts:
Regular Callouts: [?a]
Callout Custom Naming: [:?a:b]
Callout Internal Rolling: [:?[a][b]:c]
Cross-Template Reference: {:?a:b}
[?NPC]#NPC|1# went home. #NPC|7# #NPC|3# pulled #NPC|16# coat off and #NPC|1# reached for the shades.
Date Calls with formatting [Date:FORMAT] and [FGDate:FORMAT]
Insert dates into your stories based on either the computer clock or FGU calendar. Date calls the date from your computer clock and FGDate from the Fantasy Grounds calendar. You will need to load the calendar first before working with this template function.
You can enter the below strings in any way or order you wish within the callout, and it will work.
You can make up your own formats like [Date:The ddd of month, in the year yyyy] or [FGDate:dd/mm: yy] as examples. Fantasy calendars are now supported for [FGDate:FORMAT] callouts.
For these examples, assume the date is November 2 1984"yyyy" = 1984"yy" = 84"month" = November"mm" = 11"mmm" = Nov (only works with Gregorian Calendar. Fantasy Calendars don't have abbreviations stored anywhere to use for this)"day" = Friday"dd" = 2"ddd" = 2nd (adds a numerical suffix ie: 1st, 2nd, 3rd, 4th etc.)"epoch" = AD"oldschool" = Friday, the 2nd of November, in the year of our Lord: Nineteen Hundred and Eighty Four (Still only works with the system calendar/[Date:FORMAT], not a fantasy calendar/[FGDate:FORMAT].)
Cross-Template Referencing!!! (aka "passing parameters in") {:a:b} to call/store, {b}, and {#b|3#} to reference/retrieve
Use rolled results from one template, within other templates!
Table ‘a’ has 4 columns of data
Story Template 1{:a:b} = Prints col1 col2 col3 col4
This stores the output for later use.
Story Template 2{b} = Prints table a’s output as it retrieves the rolled result and prints col1 col2 col3 col4{#b|4#} = Prints only the table result of ‘a’ that is col4
This will persist while the campaign is running, but will not be available on a reload of the campaign.