Yes, you're right. I'm sorry I got carried away..
So, how did I solve it :
Is used the advice of p7r and used signals instead, so, my code looks like that now :
class_name TurnQueue
onready var active_character
func _ready():
initialize()
func initialize():
var mobs = get_mobs()
mobs.sort_custom(self, "sort_mobs")
for mob in mobs:
mob.raise()
active_character = get_child(0)
active_character.play_turn()
static func sort_mobs(a, b):
return a.speed > b.speed
func play_turn():
yield(active_character, "completed")
var new_index : int = (active_character.get_index() + 1) % get_child_count()
active_character = get_child(new_index)
active_character.play_turn()
func get_mobs():
return get_children()
Now here is the solution : On your active_character, you need to create a signal using
signal completed
After that, in your play_turn() function inside of your actual character, you need to make him take his turn (creating a scene with some buttons that you can load and use for exemple), and THEN use
emit_signal("completed")
When you figure out how to use the yield function, it becomes quite handful, especially for scenarios when you need to wait for your player to take a choice.