Documentation menu

Format reference

Option

An option is a choice the player can pick on a node. Option ids are unique within their node (OSF119).

Option that ends the dialogue

OSF.osf source
scene.osf
Dialogue scene {
  Node node_01 {
    text: "Anything else?"

    Option bye {
      text: "Bye"  // no next: choosing it ends the dialogue
    }
  }
}
scene.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: scene
  startNode: node_01
  nodes:
    node_01:
      content:
        text: Anything else?
      options:
        bye:
          content:
            text: Bye # no next: choosing it ends the dialogue

Option that leads to the next node

OSF.osf source
scene.osf
Dialogue scene {
  Node node_01 {
    text: "Hello."

    Option how_are_you {
      text: "How are you?"
      next: node_02
    }
  }

  Node node_02 {
    text: "Fine, thanks."
  }
}
scene.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: scene
  startNode: node_01
  nodes:
    node_01:
      content:
        text: Hello.
      options:
        how_are_you:
          next: node_02
          content:
            text: How are you?
    node_02:
      content:
        text: Fine, thanks.

Option that starts another dialogue

OSF.osf source
01_intro_scene.osf
Dialogue 01_intro_scene {
  Node node_03 {
    text: "Am I dreaming?"

    Option say_no {
      text: "No. Fool"
      next: Dialogue.02_shadows_speak  // starts the other dialogue at its start node
    }
  }
}
01_intro_scene.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: 01_intro_scene
  startNode: node_03
  nodes:
    node_03:
      content:
        text: Am I dreaming?
      options:
        say_no:
          next: Dialogue.02_shadows_speak # starts the other dialogue at its start node
          content:
            text: No. Fool

Option with required variables

OSF.osf source
scene.osf
Dialogue scene {
  Node node_01 {
    text: "The door is locked."

    Option leave {
      text: "Bye"
      requires: { is_dreaming: true, gold: 0 }  // shown only when every condition is met
    }
  }
}
scene.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: scene
  startNode: node_01
  nodes:
    node_01:
      content:
        text: The door is locked.
      options:
        leave:
          requires: # shown only when every condition is met
            is_dreaming: true
            gold: 0
          content:
            text: Bye

Option with alternatives

requires can join several maps with or. Every entry inside one { } must be met, and one met map is enough. A map can also check one variable more than once, for a range. Kael sells the lantern to a player with 3 to 20 gold who has none yet, or to anyone in god mode:

OSF.osf source
shop.osf
Dialogue shop {
  Node counter {
    speaker: kael
    text: "Lanterns, three to twenty coins."

    Option buy_lantern {
      text: "I will take the lantern."
      requires:
        { gold >= 3, gold <= 20, has_lantern: false }
        or { god_mode: true }
      set: { has_lantern: true }
    }

    Option bye {
      text: "Just looking."
    }
  }
}
shop.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: shop
  startNode: counter
  nodes:
    counter:
      content:
        speaker: Character.kael
        text: Lanterns, three to twenty coins.
      options:
        buy_lantern:
          requires:
            any:
              - all:
                  - {variable: gold, operator: ">=", value: 3}
                  - {variable: gold, operator: "<=", value: 20}
                  - {variable: has_lantern, operator: "==", value: false}
              - all:
                  - {variable: god_mode, operator: "==", value: true}
          set:
            has_lantern: true
          content:
            text: I will take the lantern.
        bye:
          content:
            text: Just looking.
  • The maps can stay on one line, as requires: { gold >= 3 } or { god_mode: true }. osf fmt keeps the line breaks you chose, and osf convert -o osf writes one map per line.
  • In YAML and JSON this is the full form of requires. all is a list of { variable, operator, value } conditions that must all be met; any is a list of all groups, of which one is enough. requires holds any or all, not both.
  • The full form has the operator == for "equals", the plain value of the short form: { variable: gold, operator: "==", value: 4 } is gold: 4.
  • The short map still works and means one all group. osf convert writes the short form whenever it says the same thing.
  • The same condition twice in one map is OSF014.

Option that checks what was played

requires can also check the play history. <node>.stateData.played: true is met once that node was entered, and <node>.options.<option>.selected: true once that option was chosen; false means not yet. Put Dialogue.<id>. in front to name a node of another dialogue. This makes a hub where each question can be asked once, and new questions appear as the story goes on: ask_rumours is offered until it is chosen, ask_room only after the rumours node was played, and ask_cellar only after the player reached the door node of the cellar dialogue.

OSF.osf source
tavern.osf
Dialogue tavern {
  Node hub {
    speaker: kael
    text: "What do you want to know?"

    Option ask_rumours {
      text: "Any rumours?"
      requires: { hub.options.ask_rumours.selected: false }
      next: rumours
    }

    Option ask_room {
      text: "And about that room?"
      requires: { rumours.stateData.played: true }
      next: room
    }

    Option ask_cellar {
      text: "What was in the cellar?"
      requires: { Dialogue.cellar.door.stateData.played: true }
      next: hub
    }

    Option bye {
      text: "Nothing. Bye."
    }
  }

  Node rumours {
    speaker: kael
    text: "They say the room upstairs is haunted."
    next: hub
  }

  Node room {
    speaker: kael
    text: "Nobody sleeps there twice."
    next: hub
  }
}
tavern.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: tavern
  startNode: hub
  nodes:
    hub:
      content:
        speaker: Character.kael
        text: What do you want to know?
      options:
        ask_rumours:
          requires:
            hub.options.ask_rumours.selected: false
          next: rumours
          content:
            text: Any rumours?
        ask_room:
          requires:
            rumours.stateData.played: true
          next: room
          content:
            text: And about that room?
        ask_cellar:
          requires:
            Dialogue.cellar.door.stateData.played: true
          next: hub
          content:
            text: What was in the cellar?
        bye:
          content:
            text: Nothing. Bye.
    rumours:
      next: hub
      content:
        speaker: Character.kael
        text: They say the room upstairs is haunted.
    room:
      next: hub
      content:
        speaker: Character.kael
        text: Nobody sleeps there twice.
  • History conditions are compared with true or false only, and belong in requires, never in set (OSF127).
  • An unknown node is OSF113, an unknown dialogue OSF114, and an option the node does not have OSF126.
  • A node counts as played from the moment it is entered, so a node can check its own stateData.played in its options.

Option with conditional next

Like a node, an option can branch with next ... requires. Choosing it follows the first branch whose conditions are met, else its plain next:

OSF.osf source
inn.osf
Dialogue inn {
  Node ask {
    speaker: kael
    text: "Need a bed?"

    Option take_room {
      text: "Yes, please."
      next: room requires { gold >= 3 }
      next: no_money
    }
  }

  Node room {
    speaker: kael
    text: "Upstairs, second door."
  }

  Node no_money {
    speaker: kael
    text: "Come back when you can pay."
  }
}
inn.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: inn
  startNode: ask
  nodes:
    ask:
      content:
        speaker: Character.kael
        text: Need a bed?
      options:
        take_room:
          next:
            - to: room
              requires:
                gold:
                  operator: '>='
                  value: 3
            - to: no_money
          content:
            text: Yes, please.
    room:
      content:
        speaker: Character.kael
        text: Upstairs, second door.
    no_money:
      content:
        speaker: Character.kael
        text: Come back when you can pay.

Option that sets variables

OSF.osf source
scene.osf
Dialogue scene {
  Node node_01 {
    text: "Am I dreaming?"

    Option say_yes {
      text: "Yes, you are."
      set: { is_dreaming: true }  // applied when the player chooses it
      next: node_02
    }
  }

  Node node_02 {
    text: "Strange"
  }
}
scene.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: scene
  startNode: node_01
  nodes:
    node_01:
      content:
        text: Am I dreaming?
      options:
        say_yes:
          set: # applied when the player chooses it
            is_dreaming: true
          next: node_02
          content:
            text: Yes, you are.
    node_02:
      content:
        text: Strange

Changing and comparing numbers

Numbers can do more than equal and set. Kael lets the player pay only with at least three coins and some trust, and the payment takes the coins and adds trust:

OSF.osf source
inn.osf
Dialogue inn {
  Node ask {
    speaker: kael
    text: "A bed for the night is three coins."

    Option pay {
      text: "Here are three coins."
      requires: { gold >= 3, trust != -1 }  // compare a number: != < <= > >=
      set: { gold -= 3, trust += 1 }        // change a number: += and -=
    }

    Option leave {
      text: "Too much."
    }
  }
}
inn.yaml
apiVersion: dialogue/v1
kind: Dialogue
data:
  id: inn
  startNode: ask
  nodes:
    ask:
      content:
        speaker: Character.kael
        text: A bed for the night is three coins.
      options:
        pay:
          requires: # compare a number: != < <= > >=
            gold:
              operator: '>='
              value: 3
            trust:
              operator: '!='
              value: -1
          set: # change a number: += and -=
            gold:
              operation: subtract
              value: 3
            trust:
              operation: add
              value: 1
          content:
            text: Here are three coins.
        leave:
          content:
            text: Too much.
.osfWhereMeaningYAML / JSON
name: valuesetSet the variable.the value
name += n, name -= nsetAdd or subtract n, which is 0 or more (OSF206).{ operation: add, value: n }, { operation: subtract, value: n }
name: valuerequiresThe variable equals the value.the value, or { variable, operator: "==", value } in the full form
name != n, name < n, name <= n, name > n, name >= nrequiresThe comparison is true.{ operator: ">=", value: n }
  • Operations and comparisons are for Number and UnsignedNumber only; on a Boolean they are OSF205.
  • An UnsignedNumber never goes below 0: subtracting more than it holds leaves 0, and setting it to a negative value is OSF201. A result stays within 32 bits.
  • A variable appears at most once in one set (OSF014). A requires map may compare it several times, as in { gold >= 3, gold <= 10 }, but not with the same condition twice.

Fields

.osfYAML / JSONValue
textcontent.textText. Required.
nextnextAs for nodes, including branches; omit to end the dialogue.
requiresrequiresConditions on variables and play history; the option is shown only when all are met, or all of one alternative.
setsetVariable changes, applied when the option is chosen.

requires

A map of variable ids to conditions that must all be met for the option to be shown: a plain value for equality, or a comparison for numbers. Keys can also be history conditions, and several maps joined by or are alternatives. An option without requires is always shown. If every option of a node is hidden, the node is a dead end; osf play -coverage finds these.