Using Story Templates to Create Random Stories

Introduction

A Story template is a special kind of record that can generate new story records from other information in the same campaign. 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. New story records can be generated from the template by clicking on the "Generate" button at the bottom of the story template record window.

As part of the generation of the new story record, the template will look for special text information that it will generate replacements for. The new story record will be placed into the current campaign story listing, and the story record will be displayed.

Template Example

To illustrate the potential of this new feature let us walk through an example. We'll create a Template which we can use any number of times to generate a general store that the PCs might visit during their travels. We want it to have a name, a brief description of the proprietor and the building and also we want a list of goods that are for sale. We could also place a limit on the number of gold pieces that the store might have available to buy surplus gear from the party and also work out how expensive the goods are in the shop.

Preparation

In order to achieve all of this we are going to need a large number of tables that our template will use to generate our story entry. We want a table for the first and last name of the business and one each for the exterior and interior description. We'll also need some tables to describe the proprietor and a few more tables from which we can generate stock. The graphic on the right shows some of the tables that I created for this example.

As you can see most of them are straightforward and very simple tables. Note, however he Magic Item Stock table. This one rolls a random number of times on a table from the Dungeon Master's Guide. In order for the Template to work this module will need to be open in the Library. For more information on creating tables see the tables article.

Getting Started

Once you have all of your resources in place you can start building your template. Click on Story from the menu down the right hand side and then on the 'Templates' button on the top of the window that opens to create a new, blank, template.

A Template is very like a normal story entry in many respects and so it will accept formatted text including headings, bold, italic, tables, lists and speech bubbles. So let's give the Template a name 'The Village Store'.

First up we want to give the store a description including a name. So we can create a new heading 'Building' and under that we can start creating the template. Type in 'Name:' and then after it put the name of the tables we will be using for the shop's name; so we end up with:

Name: [Name One] [Name Two]

When you generate the story from this template it will print out 'Name:' onto the story and it will then call the table [Name One] where it will roll a random entry from that table and place it in the story replacing [Name One]. It will then do the same for [Name Two]. What you end up with then is something like 'Name: Bob's Shop'. Anywhere that you want the template to access a table and get a result from that table you enclose the table name in the template with square brackets [ ].

So go ahead and fill out the first part of the Template with the description of the building and the proprietor. If you then click on the 'Generate' button at the bottom of your template a new story will be created and, if all has gone well, it will have filled in the table names with the results of rolling on those tables. You should end up with something approaching the graphic ion the right.

More Complex

Next up we'll tackle the store's inventory. For the purpose of this example the store will contain a bit of everything, some gear, weapons, armor and a magic item or two. If you look at the graphic on the right you'll see all the possibilities for calling a table from a template. Not only can we simply add the table name but we can also call the table a number of times including a random number of times.

For the weapons we have decided to roll 1d6 times on our weapons table so the syntax for that is [1d6x][Weapons Stock]. This is exactly the same syntax that you would use in a table to call another table a random number of times. For Gear we want a certain minimum number so we have used [1d10+4] which will give us between 5 and 14 items of gear. For Armor we just want two items so we have just called the armor table we created twice in two separate lines. The Magic Items we have done a slightly different way by creating a table which calls another table from the Dungeon Master's Guide a random number of times.

Note that we have linked the items in the tables we are calling so the template recreates those links in the story entry and those can then be dragged to a parcel or to a player or the whole story can be shared with a player or the entire group.

The graphic above shows how we've built the template to include the stock items and the resulting story entry.

Numbers only

We don't need to call tables in the template, we can also use random numbers to generate information. In our case we want to have a limit to the number of gold pieces that the shop has available and also to have a number we can refer to when calculating how much more expensive the items for sale are compared to the normal prices. To do this we once again need square brackets but this time we just put in a dice function. So if we want a random number between 1 and 5 we need [1d6]. The graphic on the right shows the two functions we need to create the gold prices and the percentage price increase.

A Chat Bubble

Story Templates have one last thing that we can do; we can create a speech bubble which can include some of the information that we have randomly generated. To do this we create a sentence or two of text and where we want to insert one of the randomly generated items in our template we insert the same name as the table we called but this time we use <> instead of square brackets. For example the name of our store is [Name One][Name Two]; to include this in a sentence we would write something like:

The name of the store is <Name One> < Name Two>.

When the story is generated from the template whatever is in the brackets is replaced with the results that were previously rolled up on the tables.

The graphic above shows the template structure and the final text after the story has been generated.

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:

https://www.youtube.com/watch?v=FKI3e6mHG3I

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: Gnome col2: female col3: Gribbles col4: 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.

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.

Rolled on the NPC table four times and stored results within each new name.

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.

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.

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}

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.

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.