Question
Hello everyone! I am very new to Godot so I am not sure if this is the best place to ask. I've watched quite a few tutorials and have had AI try to help me but I can't quite figure this out.
I am trying to make a fish-tank simulator game where you can buy fish and tanks and put them in your room. I have quite a few scenes - one of which is called “maintank” which is the room where you can set up your first tank. As part of maintank, I have a child (? which is also its own tscn) called “inventory” and inventory has its own child (? also another tscn) called “iteminfo”.
The idea is that when you buy a tank from the shop it adds to your inventory. And then when you click on the item in your inventory, a box (iteminfo) pops up with more information. From here the use button attached to iteminfo script would put that tank in the maintank scene.
As I am so new, I am not sure what the best way to go about this is. I have tried making iteminfo’s use function replace the texture of the sprite2d in maintank (placeditem) with the one that has been used in the inventory using the following code:
```gd
func _on_use_pressed() → void:
for i in Global.inventory:
if Global.inventory[i][“Name”] == ItemName:
ItemCount -=1
var tex = Global.inventory[i][“icon”]
var root = get_tree().root
get_node(“/root/maintank/Placeditem”).texture = Global.inventory[i][“icon”]
if ItemCount == 0:
var tempDic = {}
for x in Global.inventory:
if x > i:
tempDic[x-1] = Global.inventory
elif x < i:
tempDic = Global.inventory
Global.inventory.clear()
Global.inventory = tempDic
_on_close_pressed()
else:
Global.inventory[i][“Count”] -=1
get_node(“../inventorycontainer”).fillInventorySlots()
```
But it’s saying the game cannot find Placeditem anywhere?! I have also tried making Placeditem an autoload but that has come with a variety of its own issues (like the image just popping up everywhere that i don’t want it to??). Chatgpt and Google AI have said that making the grandparent node (maintank) use signals to iteminfo might help - but beyond not understanding what they mean, the code they provide has not worked and has often seemed to break things more than help anything.
Would anyone be able to help? thank you!
