From 9ffb1eff073872df449a957c20154b9cc77f7ef7 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 19 Nov 2025 17:30:23 +0200 Subject: Use get_node(name) instead of get_child(n) in Top --- top.gd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'top.gd') diff --git a/top.gd b/top.gd index 943d446..9c6f483 100644 --- a/top.gd +++ b/top.gd @@ -8,6 +8,7 @@ var save_state = ConfigFile.new() # Called when the node enters the scene tree for the first time. func _ready() -> void: var room = initial_room.instantiate() + room.name = "active_room" add_child(room) # Testing @@ -20,10 +21,11 @@ func _ready() -> void: func change_room(room_name: String): var room = ResourceLoader.load("res://room_" + room_name + ".tscn") - var current_room = get_child(0) + var current_room = get_node("active_room") remove_child(current_room) - var next_room = room.instantiate() + var next_room: Node = room.instantiate() + next_room.name = "active_room" add_child(next_room) func save(): -- cgit v1.3