This is my spaghetti code :)
In the global file, i have a dictionary for the dialogs (to unlock items/passages) and for the items (to be picked up and added to inventory).
var Data = {
"Collected Objects": [],
"Texts": [],
"Unlocked_Doors":{ "Alchemy Lab Door": false,
"Corridor01 Door": false,
"Corridor02 Door": false,
"Corridor03 Door": false,
"Corridor04 Door": false,
"Corridor05 Door": false,
"Kitchen Door": false,
"Outside Door": false,
"Room05 Door": false,
"Room08 Door": false,
"Secret Room Door": false,
"Secret Society Door": false,
}
# {} = Dictionary, set of data that contains info, strings, lists, other dictionaries [] = List
var Game_Objects = [
"Cane",
"Doc Coat",
"Empty Jar",
"Filter Jar",
"Firefly",
"Game Piece 1",
"Game Piece 2",
"Game Piece 3",
"Gold",
"Ingredient A",
"Ingredient B",
"Ingredient C",
"Ingredient D",
"Ingredient E",
"Jar Blue Filter",
"Jar Glow Fireflies",
"Jar Glow Urine",
"Loaf Bread",
"Mandolin String",
"Medallion",
"Potato",
"Potion",
"Recipie",
"Ring",
"Rock",
"Scroll",
"Soup",
"Urine"
]
On each room I have called this action to check if the item is there, then add it to the itemlist and show an image of it and remove it from the scene.
func remove_objects_from_scene():
if Global.Data["Collected Objects"]:
for item in Global.Data["Collected Objects"]:
remove_item_from_scene(item)
if Global.Data["Texts"]:
for item in Global.Data["Texts"]:
remove_item_from_scene(item)
func remove_item_from_scene (item):
for child in self.get_children():
if item == child.name:
get_node("./%s" %item).queue_free()