extends Button @onready var button = $"." @onready var main_menu = $".." var world_scene = preload("res://scenes/world.tscn") func _ready(): print("ready") enable() func test(): print("test") func enable(): $".".pressed.connect(self._button_pressed) func disable(): $".".pressed.disconnect() func _button_pressed(): if ("quit" in name): get_tree().quit() elif ("new_world" in name): get_tree().change_scene_to_packed(world_scene) World.new_world() elif ("load_world" in name): #assert(get_tree().change_scene_to_packed(world_scene) == OK) #get_tree().change_scene_to_packed(world_scene) var world_scene_instance = world_scene.instantiate(); world_scene_instance.name = "world" var a = $"/root/Main menu" print(str(a)) get_tree().root.add_child(world_scene_instance) get_tree().root.remove_child(a) World.load_world("world") elif ("save_world" in name): World.save_world() elif ("save_exit" in name): World.save_world() get_tree().change_scene_to_file("res://scenes/UI/main_menu.tscn") elif ("exit_nosave" in name): get_tree().change_scene_to_file("res://scenes/UI/main_menu.tscn")