From 324ef5f5e6ac5e31fd6edc9b68b32feb365a27d9 Mon Sep 17 00:00:00 2001 From: Matteo Piovanelli Date: Thu, 14 Jul 2022 17:21:24 +0200 Subject: [PATCH] fix: Correctly get inventory objects registered in other rooms (#608) --- .../game/core-scripts/esc/esc_object_manager.gd | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd b/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd index 663ef8d8..d8a6346d 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd @@ -296,6 +296,17 @@ func get_object(global_id: String, room: ESCRoom = null) -> ESCObject: "Object with global id %s in room instance (%s, %s) not found." % [global_id, room_key.room_global_id, room_key.room_instance_id] ) + if escoria.inventory_manager.inventory_has(global_id): + # item is in the inventory and may be registered to a different room + for single_room in room_objects: + # these are arrays of the objects still registered for each room + if single_room.objects.has(global_id): + escoria.logger.info( + self, + "Object with global id %s found in room instance (%s, %s) through the inventory." + % [global_id, room_key.room_global_id, room_key.room_instance_id] + ) + return single_room.objects[global_id] return null