Hi,
I am going through the Discovering Godot course. I got to the point where i need to reload the scene but the line get_tree().reload_current_scene() doesn’t work for me, the scene doesn’t seem to reload at all as the Line Editor never shows up again and nothing seems to be reloaded/reactivated. I used a break point and the line does execute with no exceptions. Any idea why it doesn’t work?
here is the code:
extends Control
onready var DisplayText: Node = $VBoxContainer/DisplayText
onready var PlayerText: Node = $VBoxContainer/HBoxContainer/PlayerText
var words: Array
var prompts: Array = ["verb","adjective","adjective"]
var story = "the sad monk went %s and then became %s when he ended his journey he became %s"
func _ready():
DisplayText.text = "Welcome to Looney Lips "
check_words_input()
func _on_PlayerText_text_entered(new_text: String):
get_word()
func _on_Button_pressed():
if is_story_done():
reset_game()
else:
get_word()
func get_word():
add_player_word()
check_words_input()
func is_story_done():
return words.size() == prompts.size()
func add_player_word():
words.append(PlayerText.text)
DisplayText.text = ""
PlayerText.clear()
func tell_story():
DisplayText.text = story % words
func show_prompt():
DisplayText.text += "Please write a " + prompts[words.size()]
func check_words_input():
if (is_story_done()):
end_game()
else:
show_prompt()
func end_game():
PlayerText.queue_free()
tell_story()
func reset_game():
get_tree().reload_current_scene()