Format reference
Variable
Story state that options can require and nodes or options can set. In set and requires, a variable is referenced by its bare id; in text, {{ Variable.<id> }} shows its current value. In .osf a variable is one line: id, type and default, which are required, and an optional description.
Schema: Boolean
OSF.osf source
variables/is_player_alive.osf
Variable is_player_alive: Boolean = truewritten by
osf convertvariables/variables/is_player_alive.yaml
apiVersion: story/v1
kind: Variable
data:
id: is_player_alive
type: boolean
default: trueSchema: Number
OSF.osf source
variables/trust.osf
Variable trust: Number = -1written by
osf convertvariables/variables/trust.yaml
apiVersion: story/v1
kind: Variable
data:
id: trust
type: number
default: -1Schema: UnsignedNumber
OSF.osf source
variables/gold.osf
Variable gold: UnsignedNumber = 70written by
osf convertvariables/variables/gold.yaml
apiVersion: story/v1
kind: Variable
data:
id: gold
type: unsignedNumber
default: 70Description
A variable can carry an optional description: a note for writers and programmers about what it tracks. Players never see it, it is not translated and it takes no {{ }} references. In .osf it follows the default, as { description = "..." } on the same line.
OSF.osf source
variables/gold.osf
Variable gold: UnsignedNumber = 70 { description = "Coins the player carries." }written by
osf convertvariables/variables/gold.yaml
apiVersion: story/v1
kind: Variable
data:
id: gold
type: unsignedNumber
default: 70
description: Coins the player carries.Types
| .osf | YAML / JSON | Holds |
|---|---|---|
Boolean | boolean | true or false. |
Number | number | A whole number, can go below 0. |
UnsignedNumber | unsignedNumber | A whole number that never goes below 0. |
- The default must have the variable’s type, and an
UnsignedNumbercannot start below 0 (OSF202). An unknown type isOSF203. - Numbers of both types are whole and fit in a 32-bit signed integer, -2147483648 to 2147483647 (
OSF204). - There are no text variables. To vary wording, write the variants as separate texts and choose between them with a variable and
requires.
Changing and comparing numbers
A Number or UnsignedNumber can be changed with += and -= in set, and compared with !=, <, <=, > and >= in requires. See Option.