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 |
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}
.
Function Calls
Before calling the functions in the written Dialogue, you need to set the caller
: the Object
from which the function will be called.
You can do that using Stage.add_caller()
.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.
After that, you can call any script functions or built-in functions that are available in the caller.
If the caller is a Node
or inherits Node
, it will be removed automatically from the Stage if its freed. You can also remove caller manually with Stage.remove_caller()
.
All functions on a Dialogue line are called with the order they are written. The following Dialogue will call one()
, two()
, and three()
subsequently.
Passing Arguments
You can generally pass any data type in the function.
You can also write expressions.
Although, datatype 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!
Positional Function Calls
Just like Dialogue tags, functions can also be called at specific point in the written Dialogue.
Dia:
"Let me brighten up the room a little...{d = 1.1}
{0}
there we go."
Background.set_brightness(1.0)
The {0}
tag indicates that it will call the first function: Background.set_brightness(1.2)
. Use zero based index to call functions, based on their order.
The rest of the functions that are not called at a specific position will be called immediately.
Ritsu:
"Such a lovely weather today!{d=0.9}
{1}
delay=1.5
{2}
I spoke too soon...."
# {0}
Portrait.set("ritsu_smile.png")
# {1}
Environment.set_weather("storm")
# {2}
Portrait.set("ritsu_pissed.png")
BBCodes
Dialogue has partial supports for BBCodes: the [img]
tag are not supported for now. DialogueLabel
will always have the bbcode_enabled
property set to true
. You can use BBCodes alongside variables and dialogue tags too.
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.