Documentation menu

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 = true
variables/variables/is_player_alive.yaml
apiVersion: story/v1
kind: Variable
data:
  id: is_player_alive
  type: boolean
  default: true

Schema: Number

OSF.osf source
variables/trust.osf
Variable trust: Number = -1
variables/variables/trust.yaml
apiVersion: story/v1
kind: Variable
data:
  id: trust
  type: number
  default: -1

Schema: UnsignedNumber

OSF.osf source
variables/gold.osf
Variable gold: UnsignedNumber = 70
variables/variables/gold.yaml
apiVersion: story/v1
kind: Variable
data:
  id: gold
  type: unsignedNumber
  default: 70

Description

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." }
variables/variables/gold.yaml
apiVersion: story/v1
kind: Variable
data:
  id: gold
  type: unsignedNumber
  default: 70
  description: Coins the player carries.

Types

.osfYAML / JSONHolds
Booleanbooleantrue or false.
NumbernumberA whole number, can go below 0.
UnsignedNumberunsignedNumberA whole number that never goes below 0.
  • The default must have the variable’s type, and an UnsignedNumber cannot start below 0 (OSF202). An unknown type is OSF203.
  • 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.