Dialogue Syntax
This page covers the syntax of the written Dialogue
and its features.
Dialogue text file needs to be saved as *.dlg
. Dialogue text/string needs to have at least one actor's name with :
at the end, and the dialogue body indented:
Newlines
Even though the dialogue above has multiple newline breaks, it will be rendered without the newline:
You can insert newlines by using{n}
dialogue variable..
Actor's Name
For dialogue lines that use the same actor, You can leave the following actor's name blank, leaving :
alone. It will use the last declared actor's name.
Leave the actor's name blank, by using a single underscore _
.
Variables
Insert variables by wrapping the variables name inside curly brackets: {_}
.
{player}:
"Please call my name, I need to demonstrate
the variable use in the written Dialogue."
Ritsu:
"O-okay?... hello {player}!"
Define the variable using Stage.set_variable()
.
You can also define multiple variables using Stage.merge_variables
with a Dictionary
.
Built-in Variables
Tags | Description |
---|---|
{n} |
Newline |
{spc} |
Space |
{eq} |
Equal sign = |
Warning
You can't use names for variables that are used by Theatre. This includes:
{n}
, {d}
, {w}
, {s}
, {spc}
, {delay}
, {wait}
, {speed}
, and function calls indexes.
Variables using any of these names will be ignored or treated as the built-in tags/variables.
Tags
There are several built-in tags to fine-tune your Dialogue flows. Tags can have several aliases: {delay = 1.0}
can also be written as {d = 1.0}
.
Tag syntax
Tag can be written inbetween dialogue string:
Or in a newline Newline tag does not use curly brackets and spaces.delay/wait
- Pause the text render at its position for
t
seconds.
speed
- Change the text progress' speed at its position by
s
times. Revert back to normal speed (s = 1
) when the Dialogue line is finished. - You can also revert the speed back with
{s}
, which is equivalent to{s = 1.0}
.
Calling Functions & Changing Properties
Scopes
Before calling functions or changing any properties in the written Dialogue, you need to set the scope
: the Object
from which the functions will be called, or its properties to be changed from within the written Dialogue.
Use Stage.add_scope()
to add a scope to a Stage
.The first argument is the id that will be used in the written Dialogue. The second argument must be an Object
class or anything that inherits that. Name the scope's id, the way you would name a variable or a class in GDScript.
Add multiple scopes at once, using Stage.merge_scoped()
, that takes a Dictionary format instead:
Note
You should set the scopes before starting any Dialogues.
If the scope is a Node
or inherits Node
, it will be removed automatically from the Stage
if its freed. You can also remove scope manually using Stage.remove_scope()
.
Removes all scopes of a Stage
using Stage.clear_scopes()
:
Syntax
After setting up the scopes, you can call any functions, or manipulate properties that are available in the scope.
All functions on a Dialogue line are called with the order they are written. The following Dialogue will call one()
, two()
, and three()
subsequently.
Arguments & Expressions
You can generally pass any data type as the function calls arguments, or as the property's value.
You can also write expressions.
Although, built-in constants are not supported for now.
# ❌ Not supported:
Button.set_color(Color.BLUE)
Player.rotate(Vector.RIGHT)
# ✅ Use these instead:
Button.set_color(Color("#0000FF"))
Player.rotate(Vector2(0, 1))
Function syntax
Write function calls (including all of its arguments) in a single line only!
Positions
Functions will be called, and properties will be set, when the Dialogue
has rendered/reached the exact positions they were written on:
In the Dialogue
line above, the foo()
function will be called immediately after the Dialogue
progressed to this line. And the bar()
function will be called after the whole Dialogue
line has fully been rendered. The same also applies to setting properties.
You can also place them in the middle of the Dialogue
content.
Ritsu:
Portrait.set("ritsu_smile.png")
"Such a lovely weather today!{d = 1.5}
Environment.set_weather("storm")
delay=1.5
Portrait.set("ritsu_pissed.png")
nevermind..."
BBCodes
Warning
Dialogue has partial supports for BBCodes: the [img]
tag are not supported for now.
You can use BBCodes alongside variables and dialogue tags. DialogueLabel
will always have the bbcode_enabled
property set to true
.
There's also several shorthand aliases for BBCode tags:
Shorthand | BBCode tag |
---|---|
[c] , [col] |
[color] |
[bg] |
[bgcolor] |
[fg] |
[fgcolor] |
\[ |
[lb] |
\] |
[rb] |
The escaped square brackets: \[
and \]
, are actually shorthands for [rb]
and [lb]
. So, rather than writing:
Dia:
"There are three main classes of the Theatre plugin:
[color=blue]Dialogue[/color],
[color=green]DialogueLabel[/color], &
[color=red]Stage[/color],
"
You can write:
Dia:
"There are three main classes of the Theatre plugin:
[c=blue]Dialogue[/c],
[c=green]DialogueLabel[/c], &
[c=red]Stage[/c],
"
Sections
Define a section in dialogue with :section_name
.
Dia:
"This Dialogue line can be skipped!"
:some_section
Dia:
"You can jump to any defined section
in the written Dialogue"
You can start a Dialogue
at a specific section.
Or go to a section in the middle of a Dialogue
using jump_to_section()
or jump_to()
.
Comments
Write comments by placing #
at the start of a new line.