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
Dialogue scene {
Node node_01 {
text: "Anything else?"
Option bye {
text: "Bye" // no next: choosing it ends the dialogue
}
}
}osf convertapiVersion: 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 dialogueOption that leads to the next node
Dialogue scene {
Node node_01 {
text: "Hello."
Option how_are_you {
text: "How are you?"
next: node_02
}
}
Node node_02 {
text: "Fine, thanks."
}
}osf convertapiVersion: 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
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
}
}
}osf convertapiVersion: 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. FoolOption with required variables
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
}
}
}osf convertapiVersion: 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: ByeOption 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:
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."
}
}
}osf convertapiVersion: 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 fmtkeeps the line breaks you chose, andosf convert -o osfwrites one map per line. - In YAML and JSON this is the full form of
requires.allis a list of{ variable, operator, value }conditions that must all be met;anyis a list ofallgroups, of which one is enough.requiresholdsanyorall, not both. - The full form has the operator
==for "equals", the plain value of the short form:{ variable: gold, operator: "==", value: 4 }isgold: 4. - The short map still works and means one
allgroup.osf convertwrites 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.
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
}
}osf convertapiVersion: 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
trueorfalseonly, and belong inrequires, never inset(OSF127). - An unknown node is
OSF113, an unknown dialogueOSF114, and an option the node does not haveOSF126. - A node counts as played from the moment it is entered, so a node can check its own
stateData.playedin 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:
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."
}
}osf convertapiVersion: 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
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"
}
}osf convertapiVersion: 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: StrangeChanging 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:
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."
}
}
}osf convertapiVersion: 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.| .osf | Where | Meaning | YAML / JSON |
|---|---|---|---|
name: value | set | Set the variable. | the value |
name += n, name -= n | set | Add or subtract n, which is 0 or more (OSF206). | { operation: add, value: n }, { operation: subtract, value: n } |
name: value | requires | The variable equals the value. | the value, or { variable, operator: "==", value } in the full form |
name != n, name < n, name <= n, name > n, name >= n | requires | The comparison is true. | { operator: ">=", value: n } |
- Operations and comparisons are for
NumberandUnsignedNumberonly; on aBooleanthey areOSF205. - An
UnsignedNumbernever goes below 0: subtracting more than it holds leaves 0, and setting it to a negative value isOSF201. A result stays within 32 bits. - A variable appears at most once in one
set(OSF014). Arequiresmap may compare it several times, as in{ gold >= 3, gold <= 10 }, but not with the same condition twice.
Fields
| .osf | YAML / JSON | Value |
|---|---|---|
text | content.text | Text. Required. |
next | next | As for nodes, including branches; omit to end the dialogue. |
requires | requires | Conditions on variables and play history; the option is shown only when all are met, or all of one alternative. |
set | set | Variable 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.