Make a new item by combining two items

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheCoinCollector

I’m making a point and click game, and I’m trying to make items be combined.

I would like to combine items from my inventory (item list) with: other items on inventory and / or items on the scene.

Is it possible?

:bust_in_silhouette: Reply From: Inces

of course it is possible and there are many ways to implement this. Do You have any scene setup and code for now ? Basically You could just design match statement for all interactions of items and their results, or use exported dictionary that will define interactions with certain items, for example :

Node Candle
var interactions = {“fire” : “burning_candle”, “string” : “candle_on_string”}

when item collides with another, it will iterate through this dictionary and check if something new should be instantiated

I have started the coding, made some libraries on a Global singleton and they are called on each room/scene.
I have to admit this is the first game I aim to do without any tutorials and i feel a bit stuck atm.

Where would you suggest adding the variable for the candle?

TheCoinCollector | 2022-04-27 07:10

This is my spaghetti code :slight_smile:

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 = [
						"Doc Coat", 
						"Empty Jar", 
						"Filter Jar", 
						"Game Piece 1", 
						"Game Piece 2", 
						"Game Piece 3", 
						"Ingredient A", 
						"Ingredient B", 
						"Ingredient C", 
						"Ingredient D", 
						"Ingredient E", 
						"Jar Blue Filter", 
						"Jar Glow Fireflies", 
						"Jar Glow Urine", 
						"Loaf Bread", 
						"Mandolin String", 

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"]:
if Global.Data["Texts"]:
	for item in Global.Data["Texts"]:

func remove_item_from_scene (item):
	for child in self.get_children():
		if item ==
			get_node("./%s" %item).queue_free()

TheCoinCollector | 2022-04-27 07:12

If I understand correctly,each of your item is a node, childed to the scene or to some kind of inventory when they are collected

I would keep var interactions in this item node. I suspect You use inherited scene or class script for all of them ? If Yes, than introducing this dictionary as export comes in handy.
So every item will have var interactables, that You will modify to your liking in editor, so every item has individual values - defining what it can interact with, and what will be the result of interaction.

You surely have some kind of code, to pick up an object from inventory and click another one, to combine it. This is where You should iterate for var interactables content. Like in this pseudocode :

on_item_being_tried_to_combine_with_another ( anotheritem) :
      for entry in interactables.keys() :
             if == entry :
      printmessage("these items can't be combined")

Inces | 2022-04-27 10:25

Thank you, I will try to implement this section!!

TheCoinCollector | 2022-04-29 07:42