Does something like this work?
signal output_finished
# Called when the node enters the scene tree for the first time.
func _ready():
textbox_name.clear()
textbox_dialogue.clear()
textbox_name.add_text(event_queue[event_queue.size() - 1]["name"])
var text = event_queue[event_queue.size() - 1]["text"]
show_text(text)
yield(self, "output_finished")
event_queue.pop_back()
func show_text(text: String, rate: float = 0.1):
textbox_dialogue.visible_characters = 0
textbox_dialogue.text = text
while textbox_dialogue.visible_characters < len(text):
textbox_dialogue.visible_characters += 1
yield(get_tree().create_timer(rate), "timeout")
emit_signal("output_finished")
I put your code in the _ready()
method just because I don't know where else you have it, but you can put it wherever obviously