Documentation menu

Format reference

Playing a dialogue

This is how a player runs a project. osf play and the editor’s Play panel implement it, and a game that follows it plays every story the same way.

  • Play starts at a chosen dialogue, else the Story’s start, else the first dialogue in file order. Every Variable is set to its default, and no node has been played and no option selected yet.
  • Play enters the dialogue’s startNode. Entering a node applies its set, in the order written, then shows its line: the text, and as the speaker its title if it has one, else the speaker Character’s name, else nothing (narration).
  • A node with next goes on to it without stopping. When next is a list of branches, the first branch whose requires are met is followed; when none is, the dialogue ends. next: <node>.options goes straight to that node’s options: its line is not shown again and its set is not applied again. next: Dialogue.<id> enters that dialogue’s startNode; variables keep their values across dialogues.
  • A node with options stops and offers the options whose requires are met by the current values and play history: every condition, or every condition of one alternative. An option with no requires is always offered. Choosing one marks it selected, applies its set and follows its next; an option without next ends the play. A node counts as played from the moment it is entered.
  • A node with neither next nor options ends the play. A node whose options are all hidden by requires is a dead end: nothing can be chosen and play cannot go on.
  • Texts are shown in the chosen locale, each one falling back to the source text when it has no translation, with {{ }} references replaced.

A run of more than 10000 nodes without a choice is an infinite next loop and stops with an error.

Try it

osf play plays a project in the terminal. -dialogue starts at another dialogue, -locale shows a translation, and -choices 1,2,1 plays those choices without asking, which is handy in tests:

$ osf play -choices 1 my-story
== Dialogue intro
Guard: Halt! Who goes there?
  1. A friend.
  2. Nobody. Bye.
> 1
  [set has_key = true]
Guard: Then take this key, Guard trusts you.
== End

osf play -coverage explores every reachable path from the start dialogue and reports dead ends, options that no path can show, and loops with no exit. It exits with status 1 when it finds any, so it fits in CI next to osf validate.