Sequence of events

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AneCelOW

I want to make a sequence of events but in my code yield(self,‘moveforward_done’) doesn’t wait the moveforward() execution and starts executing do_event() function again. There is also endless moving car (loop?) because of this. How to fix this code or even make the better implementation of this idea?

signal moveforward_done

func _ready():
connect('moveforward_done',self,'moveforward')


func _on_start_btn_pressed():
	do_events()


func do_events():
	for i in right_vbox.get_children():
		if i.name.substr(0,7) == 'movecar':
			if checkb1.pressed and checkb2.pressed:	 
				path=float(lineedit.text)
				moveforward()
				yield(self,'moveforward_done')
				print('done')


func moveforward():
	car1.brake = 0
	car1.engine_force = 40
	yield(get_tree().create_timer(path), "timeout")
	car1.engine_force = 0
	car1.brake = 1
	emit_signal('moveforward_done')