From 9b5a7040c222237dabb8a5f8f90ab9654b2f7760 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 29 Apr 2026 15:54:24 -0700 Subject: [PATCH] Add get_current_room_name() helper to MainGame Provides a convenient way to identify the current room at runtime by extracting the room name from the scene script's resource path, rather than relying on node names (which are always 'background'). --- MainGame.gd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MainGame.gd b/MainGame.gd index 1aa521f..923e790 100644 --- a/MainGame.gd +++ b/MainGame.gd @@ -10,6 +10,14 @@ var is_cursor_locked: bool = false # When true, hourglass is shown and cursor c func get_scene() -> Scene: return $SceneViewport/background +func get_current_room_name() -> String: + var scene = get_scene() + if scene and scene.get_script(): + var script_path = scene.get_script().resource_path + if script_path.begins_with("res://scenes/"): + return script_path.trim_suffix(".gd").get_file() + return "" + # Called when the node enters the scene tree for the first time. func _ready(): # get_scene().connect("transitioned", Callable($SceneViewport/label, "_on_transitioned"))