Godot Dialogue Manager Language is an [[MIT License]] licensed dialogue language written in [[GDScript]].
- [Website](https://dialogue.nathanhoad.net/)
- [Source](https://github.com/nathanhoad/godot_dialogue_manager)
- [Documentation](https://github.com/nathanhoad/godot_dialogue_manager/blob/main/docs/Writing_Dialogue.md)
> Dialogue Manager is an addon for Godot 4.3+ that provides a stateless branching dialogue editor and runtime. Write your dialogue in a script-like way and easily integrate it into your game.
# Notability
Used by [[Dialogue Manager]].
# Philosophy
# Platform Support
Anywhere [[Godot]] is supported.
# Example
```
~ start
Nathan: Hi! I'm Nathan.
Nathan: Here are some options.
- First one
Nathan: You picked the first one.
- Second one
Nathan: You picked the second one.
```
# Markup
## Comments
Comments begin with a hash `#` and are ignored at runtime.
## Titles
Titles are the destinations for jump points and aren't shown to the player.
### Importing Titles
Titles can be imported from another file and namespaced to prevent naming conflicts.
```
import "res://more_titles.dialogue" as more_titles
```
And used like this:
```
=> more_titles/foobar
```
## Jumps
To redirect the dialogue to a named title use the arrow `=>` syntax.
```
=> name_of_the_title_to_jump_to
```
The above is a non-returning jump, but to jump and then return as a subroutine, suffix a less-than symbol.
```
=>< go_to_and_return_from_this_title
```
## End Dialogue
The dialogue will terminate when any of these tokens are reached:
- `=> END`
- `=> END!`
- The end of a file
## Speaker Indicator
A line may optionally be prefixed with a name followed by a colon to indicate the speaker.
```
name: line of dialogue
```
## Alternative Text
### Variations
Randomly selects from multiple alternatives each time the dialogue is encountered. Surrounded by double square brackets and separated by pipe characters.
```
Nathan: [[Hi|Hello|Howdy]]! I'm Nathan
```
### Randomized Lines
Randomly select one entire line from multiple options.
```
Nathan: I will say this.
% Nathan: And then I might say this
% Nathan: Or maybe this
% Nathan: Or even this?
```
Suffix the `%` with a number to indicate the multiplier weight.
```
%3 Nathan: This line as a 60% chance of being picked
%2 Nathan: This line has an 40% chance of being picked
```
### Randomized Jumps
Combining the randomized line syntax with the jump syntax to randomly jump to a pool of titles.
```
Nathan: Let's go somewhere random.
% => first
% => second
% => third
```
## Variables
Variables act like templates and can pull values from available globals or the Dialogue Manager settings and can access member properties. They are surrounded by curly braces and otherwise use standard [[GDScript]] syntax.
```
Nathan: The value of some_variable is {{SomeGlobal.some_property}}.
```
## Multiline
To represent multiple lines of dialogue from a single speaker, use either `\n` to separate them on a single line or indent each additional line.
```
Coco: This is the first line.
This line would show up below it in the same balloon.
And even this line.
```
For the purposes of a translation, these behave as a single line and are translated all at once.
## Options
Player responses can be chosen from a list by the player. These options are prefixed with a dash.
```
Nathan: What would you like?
- This one
- No, this one
- Nothing
```
If dialogue does not branch, then it will just continue to the next non-option line.
### Branching
Branching from an option can be done by suffixing it with the jump arrow.
```
Nathan: What would you like?
- Another one => another_title
- Nothing => END
```
### Indented Responses
Lines particular to a given option can also be indented below the option they belong to.
```
Nathan: What would you like?
- This one
Nathan: Ah, so you want this one?
```
### Character Responses
These two examples produce identical output.
```
Someone: Here is a thing you can do.
- That's good to hear!
Nathan: That's good to hear!
- That's definitely news
Nathan: That's definitely news
```
This combines speaking indicators with the options.
```
Someone: Here is a thing you can do
- Nathan: That's good to hear!
- Nathan: That's definitely news
```
## Control Structures
### Conditionals
Any line beginning with `if` is parsed as a conditional. Lines of dialogue are indented within. There is no end delimiter.
```
if SomeGlobal.some_property >= 10
Nathan: That property is greater than or equal to 10
elif SomeGlobal.some_other_property == "some value"
Nathan: Or we might be in here.
else
Nathan: If neither are true I'll say this.
```
### Loops
A line beginning with `while` is parsed as a conditional loop.
```
while SomeGlobal.some_property < 10
Nathan: The property is still less than 10 - specifically, it is {{SomeGlobal.some_property}}.
do SomeGlobal.some_property += 1
Nathan: Now, we can move on.
```
### Option Conditionals
Inside square brackets simple conditionals can also be used in player option lists to qualify responses. Options where the conditional fails will not be shown. Conditionals must come before jumps on the same line.
```
Nathan: What would you like?
- This one [if SomeGlobal.some_property == 0 or SomeGlobal.some_other_property == false]
Nathan: Ah, so you want this one?
- Another one [if SomeGlobal.some_method()] => another_title
- Nothing => END
```
These types of conditionals do not require a closing tag.
### Inline Conditionals
These types of conditionals *do* require a closing tag in the form of `[/if]`. And `else` is optional.
```
Nathan: You have {{num_apples}} [if num_apples == 1]apple[else]apples[/if], nice!
```
## State Mutation
### Set Variable
To change the state of the program, a variable's value can be set to a new value by starting a line with `set`.
```
if SomeGlobal.has_met_nathan == false
Nathan: Hi, I'm Nathan.
set SomeGlobal.has_met_nathan = true
Nathan: What can I do for you?
- Tell me more about this dialogue editor
```
### Invoke Function
A line prefixed with `do` will attempt to execute a global function that matches the given arguments. The return type of the function is assumed to be `void` because the dialogue system will not capture the result.
```
if SomeGlobal.has_met_nathan == false
do SomeGlobal.animate("Nathan", "Wave")
Nathan: Hi, I'm Nathan.
set SomeGlobal.has_met_nathan = true
```
#### Emit Signal
A built-in function to emit a signal.
```
emit(...)
```
#### Debug Log
A built-in function to print a value to the output panel.
```
debug(...)
```
#### Wait
A built-in function to wait for a certain number of seconds `N` as a floating point number. Doesn't work inline, use the Speed Control markup for that instead.
```
wait(N)
```
### Inline Mutations
Similar to other actions, they are enclosed in square brackets.
```
Nathan: I'm not sure we've met before [do wave()]I'm Nathan.
Nathan: I can also emit signals[do emit("some_signal")] inline.
```
Inline mutations that use await in their implementation will pause typing of dialogue until they resolve. To ignore awaiting, add a "`!`" after the "`do`" keyword.
```
[do! something()]
```
## Escape Characters
To disable the special meaning of characters like `:` or `[`, prefix them with a backslash `\`.
## Rich Text
The Dialogue Manager supports [[BBCode]] in the appropriate dialogue display panels to style the text.
## Speed Control
To wait a certain time before displaying the next line or to control the typing speed, use [[BBCode]]-like indicators. Specify the time or speed in seconds (represented below by `N`).
- `[wait=N]`
- `[speed=N]`
- `[next=N]`
- N = `auto` - guess wait time based on length of line
- N and `=` absent - proceed to the next line immediately
## Tags
Tags can provide additional metadata to the game to use with animations or other effects. They can be flat tags or key/value.
```
Nathan: [#happy, #surprised] Oh, Hello!
Nathan: [#mood=happy] Oh, Hello!
```
# Features
# Tips
# References