extends Node var voice_script = [ ["the_long", "book"], ["the_tall", "book"], ["the_door"], ["the_clock"], ["under_the_bed"], ["frog"], ["squirrel"], ["the_attic"], ["the_fridge"], ["the_tall", "book"], ["under_the_bed"], ["the_long", "book"], ["behind_the_bookshelf"], ] @export var impatience: float = 10.0 func stop_all(): for sound in $Sounds.get_children(): sound.stop() func _ready(): await get_tree().create_timer(5.0).timeout var _err = GlobalCursorState.connect("unchecked_goal",Callable(self,"check_goal")) script_loop() var current_phrase = null func read_line(line): current_phrase = line $Sounds/show_me.play() await $Sounds/show_me.finished for phrase in line: if completed: break var sound = get_node("Sounds/" + phrase) sound.play() await sound.finished signal sig_advance(did_time_out) func script_loop(): for line in voice_script: completed = false $ImpatienceTimer.stop() await read_line(line) $ImpatienceTimer.start(impatience) while not completed and await self.sig_advance: await read_line(line) $ImpatienceTimer.start(impatience) $ImpatienceTimer.stop() await get_tree().create_timer(3).timeout var _err = get_tree().change_scene_to_file("res://screens/finished.tscn") var completed = false func advance(): current_phrase = null $ImpatienceTimer.stop() completed = true stop_all() $Victory.play() await $Victory.finished await get_tree().create_timer(3).timeout emit_signal("sig_advance", false) func check_goal(phrase): if current_phrase == phrase: advance() func _input(_event): if Input.is_action_just_pressed("cheat"): advance() func _on_ImpatienceTimer_timeout(): emit_signal("sig_advance", true)