summaryrefslogtreecommitdiffstats
path: root/top.gd
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-11-19 17:26:53 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-11-19 17:26:53 +0200
commit30a3c440c3f18d7d2e0d6cb2e9c41f778922ba89 (patch)
treeb07961a9d24104da1d6767246f2956aee05103e6 /top.gd
parent4a7fba96222160ec02378a848714d0b7e1139d21 (diff)
Rename Root -> Top
Diffstat (limited to 'top.gd')
-rw-r--r--top.gd30
1 files changed, 30 insertions, 0 deletions
diff --git a/top.gd b/top.gd
new file mode 100644
index 0000000..943d446
--- /dev/null
+++ b/top.gd
@@ -0,0 +1,30 @@
+class_name Top
+extends Node2D
+
+@export var initial_room: PackedScene
+var save_state_path = "user://save_state.cfg"
+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()
+ add_child(room)
+
+ # Testing
+ save_state.load(save_state_path)
+ print("loaded test_item: ", save_state.get_value("items", "test_item"))
+ save_state.set_value("items", "test_item", true)
+ save_state.save(save_state_path)
+ print(OS.get_data_dir())
+
+
+func change_room(room_name: String):
+ var room = ResourceLoader.load("res://room_" + room_name + ".tscn")
+ var current_room = get_child(0)
+ remove_child(current_room)
+
+ var next_room = room.instantiate()
+ add_child(next_room)
+
+func save():
+ save_state.save("user://save_state.cfg")