I want to call yield in a function, but have that yield in another function

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zedespook
func _speak(dialogue):
	Interaction.say_dialogue(dialogue)
	yield(Interaction, "interaction_completed")

func handle_interaction() -> void:
	_speak("hello 1")
	_speak("hello 2")

Calling yield in the first call of _speak() doesn’t wait until the interaction is being completed. Is there a sophisticated way to solve this issue with signals?

The problem is mostly about code design.

func handle_interaction() -> void:
    	Interaction.say_dialogue("hello 1")
    	yield(Interaction, "interaction_completed")
    	Interaction.say_dialogue("hello 2")
    	yield(Interaction, "interaction_completed")

This looks like ugly code, specially if I have many things that a character says. Can this be solved with yield or should I go with the good old is_finished checks?

:bust_in_silhouette: Reply From: klaas

Hi,
have a look here how the data is structured …

or use an addon

Not really useful for me, but thanks for the effort.

Zedespook | 2021-07-26 21:22