Calling Functions from Dialogue
Dia:
"You can call functions from written Dialogues.
Provided that there's the Object
to call said functions: the scope."
:
"Let's use a simple ColorRect node as a scope."
:
"And we'll modify its properties
using its various setter functions."
-
Add
node to the scene. Adjust its position and size to your liking.ColorRect
MyScene ├─ TheatreStage ├─ PanelContainer │ └─ VBoxContainer │ ├─ Label │ └─ DialogueLabel └─ ColorRectAnd reference it in the script.
-
Register it as a scope in the
, usingTheatreStage
add_scope().extends Control var dlg: Dialogue # Load/create Dialogue here @export var stage: TheatreStage @onready var color_rect = $ColorRect func _input(event): if event.is_action_pressed("ui_accept"): stage.progress() func _ready(): stage.add_scope("CoolRect", color_rect) stage.start(dlg)add_scope()requires 2 arguments:- The ID/name of the scope object to be used in the written Dialogue.
- The object itself.
Here, we'll name our
asColorRect
CoolRect. -
We are ready to call functions (and even do other stuff) on our
.ColorRect