One thing that makes a game more successful and fun is the ability to support content and mods from third-parties, aka you the player.
Westernkind Games is not a huge team with a huge budget and it isn't possible to be putting out huge amounts of content.
To improve this situation, we ask the creative people out there to contribute their own content for our game engine.
The stories and lessons that make up our game are a made using a tool known as "Yarn Spinner".
You can learn more about Yarn Spinner on their website, https://yarnspinner.dev.
Not all of the features supported by Yarn Spinner are available in our game engine.
Yarn Spinner is designed to be extendable and that's what we have done by creating our own game engine that utilizes the Yarn Spinner files, or Yarns.
Westerkind Game's Story Game Engine
Otherwise known as the Story Game Engine or SGE.
This documentation, like the game itself, is a work in progress and will change over time.
Testing Your Yarn
Two pages are provided for testing yarns. Save your yarn to a json file, open the file in a text editor and copy the contents, paste the contents into the test script input.
Test Story yarns here.
Test Lesson yarns here.
Formatting Dialog and Choices
There are a few nuances to how dialog and choices, aka options, can be formatted.
An option that has the prefix "do:" in its text will be presented as an action that the player can take.
An option that has no prefix in its text will be presented as something the player can say.
A line of dialog prefixed with "player:" or "you:" will be displayed as something the player has said.
The text color will be recognizably different from the other text.
A line of dialog prefixed with "character-name:" will be displayed in as something an NPC has said.
The "character-name" portion can be any name you wish to give that character.
For example, "Frank: Hello there." would display with the words "Frank" in bold, indicating that the words following are being spoken by the character named Frank.
Expressions are fully implemented in SGE.
Yarn Spinner Expressions
Variables are fully implemented in SGE. This is a very powerful feature when combined with expressions and conditionals.
Yarn Spinner Variables
Conditionals are fully implemented in SGE, but there are a few issues with nesting certain elements with conditionals.
Yarn Spinner Conditionals
SGE supports all of the standard BBCodes, but the syntax might differ slightly from what you are used to.
BBCodes are implemented using a slightly modified version of Extendible-BBCode-Parser.
An interactive previewer can be experimented with here.
The following commands are supported by the SGE.
See the Yarn Spinner syntax reference for details about what commands are and how to use them.
Yarn Spinner Commands
- adddays (variableName, numDays)
- Adds days to a date variable. Use a negative value to subtract days. See the "setdate" command for more details.
- clearafterselect (true/false)
- Changes how the yarn nodes are displayed. Takes a true/false argument. If true, then the screen will be cleared after each selection. A "selection" would be the player clicking on one of the available options.
- Clears the screen of any text. Takes no arguments.
- Ends the current game, showing the "Game Over" text and the player's current score.
- Ends the current game, showing the "The End" text. Does not show a score.
- inputnumber (variableName, minimum, maximum)
- Receive numerical input from the player that will be stored in the specified variable and of the range minimum-maximum.
- inputtext (variableName)
- Receive text input from the player that will be stored in the specified variable.
- playsound (soundfile, [optional]volume 0.1-1.0)
Plays the specified sound file. Takes a filename and optional volume argument.
The engine assumes that the sound already exists on the server. We currently do not support playing externally stored sounds this way.
Feel free to submit sound files with your stories and we will add them to the site.
- playmusic (soundfile, [optional]volume 0.1-1.0)
Plays the specified music file. Takes a filename and optional volume argument.
The engine assumes that the sound already exists on the server. We currently do not support playing externally stored music this way.
Feel free to submit music files with your stories and we will add them to the site.
We will only host music files that are in the public domain or that we own the copyrights for.
- randomfloat (see description)
- Generates a random decimal number and stores it in a variable named "rndnum". If no arguments provided, then range is 0-1. If one argument is provided, then range is 0-arg1. If two arguments are provided then range is arg1-arg2.
- randomint(see description)
- Generates a random integer number and stores it in a variable named "rndnum". If no arguments provided, then range is 1-100. If one argument is provided, then range is 1-arg1. If two arguments are provided then range is arg1-arg2.
- scorechange (points +/- number)
- Changes the player's score by the amount of points specified.
- setdate (variableName, date)
- Sets a date variable that has many useful features. The "date" argument passed to this command must be a string in (YYYY-MM-dd), so July 1st 1999 would be "1999-7-1". After a date variable is set, there are many other variables created. These other variables, or date parts, are accessed using dot notation. If your variable name is mydate then you could get the year portion of the date with the variable $mydate.year. Currently, the date parts available are year, monthname, dayname and formatted. The date.formatted variable will be the full date using words and numbers, like "Monday, March 29, 2088" or something like that.
- setdelay (milliseconds number)
- Changes how long the pause is between display of each block of text. The value is in milliseconds, so 1000 is the same as 1 second.
- setshowactionprompt (true/false)
- Sets whether or not to display the prompt for player actions.
- setshowresponseprompt (true/false)
- Sets whether or not to display the prompt for player responses.
- setshowselection (true/false)
- Sets whether or not to display the selection that the player clicked on after they click on it. Defaults to false.
- wait (seconds number)
- Waits for the specified number of seconds before continuing.