Inkspire is a text adventure engine, designed to make building your own text adventures as easy as possible.
Execution instructions:
- Ensure that Git, Node, and NPM are installed.
- Clone the repository to your preferred machine.
- In the top level directory, run
npm install. - To launch the program, use
npm start.
To build your own text adventure, write an Adventure object in a JSON file using the format specified below.
* indicates that a field is required.
An adventure is a JSON object. Adventures are typically written in their own .json files, which can be loaded by the game. There is currently no way to write multiple adventures in the same file. Adventures have the following fields:
- title* :
textThe title of the adventure. - name* :
namespaceThe internal name of the adventure, used for internal identification. Cannot contain colons. Contains only lowercase ascii letters and underscores, by convention. - author :
textThe name of the author of this story. This name is conventionally only upper or lower case ascii characters. - version* :
intThe format version that this adventure was written to use. Currently, the only version is 1. - requires :
stringA comma separated list of other adventures that are required to be loaded for this adventure. If your adventure references a namespace other than Inkspire, it's highly recommended that you require that adventure to avoid a linking error, which occurs when that namespace does not exist. - actions :
actionActions that run when the adventure is loaded. It is recommended that you use these to set initial values for every variable used in the adventure to avoid undefined behavior. - globalTop :
textSpecifies content that appears above the content of every scene in the adventure, but below the title. - globalBottom :
textSpecifies content that appears below the content of every scene in the adventure, above the options. - startingScene :
identifierThe identifier of the scene where new players start when entering this adventure for the first time. Specifying a starting-scene in another namespace (aka. starting your adventure in a different adventure) is allowed. Defaults tostartif unspecified. - scenes* :
scene[]An array of scenes that make up this adventure.
A scene is a JSON object which includes the following fields:
- title* :
textThe title of the scene. - name* :
nameThe internal name of the scene, used for internal identification. Cannot contain colons. Contains only lowercase ascii letters, by convention. - actions
actionActions which occur every time the user enters this scene. - content* :
text[]The text paragraphs displayed during the scene, describing what happens around the player. Each string represents one paragraph. - options* :
option[]The possible choices that the player can select to continue the adventure.
An option is a JSON object which includes the following fields:
- label* :
textThe text shown to the user for this option. - target* :
identifierThe identifier for the scene to which the player is sent after clicking this option. - condition :
conditionA condition that must be met for this option to be selectable. If none is specified, the option is always selectable. - alwaysVisible :
boolWhether to show the option, even when it isn't selectable. Defaults tofalse, if unspecified. - actions
actionActions which occur every time the user selects this option.
Identifiers are a namespace and a name string in the form namespace:name. They are used to uniquely distinguish variables and values. For example, in an adventure named "palace", the "kitchen" scene has the identifier palace:kitchen. In many cases, specifying the full identifier is necessary. For example, within the palace adventure, the kitchen may be referred to without a namespace as simply kitchen, and the current adventure's namespace will be used as a default.
A condition is a string which evaluates to either true or false at any given time during the adventure.
- variable=min..max Evaluates to true if the specified variable is within the specified floating-point range. (e.g. 0.1 - exact match of 0.1. ..0.1 - less than or equal to 0.1. 0.1.. - more than or equal to 0.1. 0.1..1 - from 0.1 to 1, both inclusive.)
- condition || condition Evaluates to true if either condition is true. Using a single pipe (
|) is also valid, but cool people use||. - condition && condition Evaluates to true if both conditions are true. Using a single ampersand (
&) is also valid, but cool people use&&.
An action is a string specifying changes to the variables stored for each user. They are written in the form of a variable followed by an expression. Valid operations include =, +=, -=, *=, and /=. For example, if damage is 2 and strength is 1, then health -= damage + strength subtracts 3 from health. Note that variables from other stories need to be identified with a namespace, for example inkspire:time.
It's assumed that the user understands most basic programming types, but they are explained in minimal detail here:
- bool Either
trueorfalse(conventionally not capitalized). - string A sequence of characters.
- text A string, but with some additional features that are rerendered each time the string is displayed:
${variable}Include variables in text. It is recommended to set default values for all variables which appear in text since this standard does not define a value that should appear if an undefined variable is displayed.?{condition?text1|text2}Display text only if a condition is true. In this example, text1 displays when the condition is met, and text2 displays when it is not. Including the pipe (|), followed by text2, is optional, and defaults to no text being displayed on a false condition. However, you can opt to use aconditioninstead, which will be reevaluated each time the relevant content is displayed.
The Inkspire namespace provides several useful scenes and variables to help you bring your adventures to life.
- inkspire:switch Allows players to switch to a new adventure.
- inkspire:fail Marks the adventure as failed.
- inkspire:pass Marks the adventure as completed successfully.
- inkspire:exit Closes the game.
- inkspire:back Goes to the player's previous page.
- inkspire:failures The number of adventures this player has completed.
- author :
stringFilter only completions of stories by a specific author. Note that this is case-sensitive.
- author :
- inkspire:completions The number of adventures this player has completed.
- author :
stringFilter only completions of stories by a specific author. Note that this is case-sensitive.
- author :
- inkspire:undefined Provides the
undefinedvalue. Using this is not recommended in most situations, since all variables should have defined values to avoid undefined or inconsistent behavior. - inkspire:time The seconds since January 1, 1970.
inkspire:back[depth=2,to="inkspire"] Goes back two rooms, then continues going back until reaching a room in the inkspire namespace.