Dialogue Singleton Reference
The Dialogue
autoload is automatically set by the plugin when "enable helpers" is set in Project Settings.
It allows you to start, stop and listen to dialogues from anywhere, using the "Dialogue" singleton.
Methods
Return | Method |
---|---|
void | start_dialogue(path: String, block: String = "", speakers: Dictionary = {}) |
void | load_dialogue(path: String, block: String = "", speakers: Dictionary = {}) |
void | start() |
Variant | set_variable(var_name: String, value: Variant) |
Variant | get_variable(var_name: String) |
void | on_external_variable_fetch(callback: Callable) |
void | on_external_variable_update(callback: Callable) |
Signals
Emitted when a dialogue started.
Emitted when a dialogue ended.
Emitted when a dialogue variable changed.
Emitted when a dialogue event was triggered.
Emitted when the current line has a different speaker from the previous one.
Method descriptions
Start a dialogue. This will create the dialogue bubble based on the configuration set in the dialogue config node.
path
: Path to dialogue file. Path might be relative to the default dialogue folder (i.e 'my_dialogue') or absolute 'res://my_dialogue.clyde'block
: Start dialogue from this block. Empty string means the default block.speakers
: This is a Dictionary where the key is the speaker id/name (defined in the dialogue file), and the value is a dictionary with anything.
By default, if the value dictionary has a "variables" property, the manager will iterate over it and populate the dialogue with them.
Example:
{ "npc": { "variables": { "name": "Frodo" } } }
With the object above, name will be used as the speaker display name, and also it will be mapped to the dialogue and available to be accessed as@npc_name
. The whole object will be passed to the set_speaker method in the dialogue bubble as is.
NOTE: Variables defined via the speakers dictionary have preference over the external variable fetch callback and can't be edited via dialogue.
Setup dialogue but does not execute it. You should call start()
when ready to start dialogue.
Useful for when initial setup is required before starting.
Start pre-loaded dialogue
Set variable to current running dialogue
var_name
: variable namevalue
: variable value
Get variable from current running dialogue
var_name
: Variable name
Set callback to be used when requesting external variables. This callback should return the value for the requested variable, which will be used in the dialogue.
Set callback to be used when an external variable is updated in the dialogue