Godot Version
4.6.2
Question
Hello everyone! I am trying to make a fishtank game with multiple scenes. I have a scene for “maintank”, one for “inventory” and one for “iteminfo”. The idea is that you buy tanks from the shop, they add to your inventory (via a dictionary in a script called Global), and then you can place those tanks into your room (maintank scene) via a use button that pops up when you click on your inventory and then “use” the desired tank (iteminfo). In the game you start of with a plastic bag, and then you can update your tank → therefore in the maintank you start off with a baggy sprite2d that would hopefully change texture to the icon of the tank you “use” and everything in my script indicates that the texture should change… but it isn’t.
I have followed many tutorials and have asked AI, read forums etc - overall I have tried very hard to fix this issue on my own but as a beginner I am now totally lost. Below are all the relevant scripts that I believe are responsible for this failure to change the texture.
As for the scene tree. Main tank is the ‘parent’ with Placeditem (the sprite2d that I want to change) as a child and Inventory attached to that. Inventory is then a parent of “iteminfo” and “inventorygrid”. Inventory has no script attached to itself.
Let me know if you need any other info from me!! Really appreciate any help ![]()
Main tank script
extends Control
@onready var placeditem: Sprite2D = %Placeditem
var ItemName = ""
var ItemDes = ""
var ItemCost = 0
var ItemCount = 0
var CurrItem = 0
var select = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$inventory.hide()
Global.item_changed_globally.connect(_thissomeshit)
func _thissomeshit(item_index: int) -> void:
var item_data = Global.inventory[item_index]
print("watch dis SPACE")
print(item_data["icon"])
%Placeditem.texture = item_data.icon
%Placeditem.scale = Vector2(1, 1) # Ensure it's not tiny
%Placeditem.z_index = 100 # Ensure it's on top
%Placeditem.show() # Ensure it's not hidden
%Placeditem.position = Vector2(500, 300)
print("Placed: ", item_data.Name)
print("Texture should now be: ", item_data["Name"])
func _on_button_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/leave_house.tscn")
func _on_add_pressed() -> void:
hide()
$inventory.show()
Global script:
extends Node
signal item_changed_globally(new_index)
var gold = 1000
var tanks = {
0: {
"Name": "Baggy",
"Des": "Start here brokie!",
"Cost": 5,
"icon": preload("res://562b27c8-54ea-49fe-9ae5-2f7052fe8b55.png")
},
1: {
"Name": "Bowl",
"Des": "An upgrade! You can now start adding more fish... don't add too much though",
"Cost": 50,
"icon": preload("res://Screenshot 2026-04-20 005228.png"),
},
2: {
"Name": "Large Tank",
"Des": "This is a large tank. Suitable for more fish.",
"Cost": 200,
"icon": preload("res://Screenshot 2026-04-20 005223.png"),
},
}
var feesh = {
0: {
"Name": "Betta",
"Des": "Also known as the Siamese fighting fish, the betta is a freshwater tropical fish native to Southeast Asia. They were initially bred for aggression and subject to gambling matches akin to cockfighting.",
"Cost": 10,
"icon": preload("res://HM_Orange_M_Sarawut.jpg")
},
1: {
"Name": "Goldfish",
"Des": "The goldfish - a fresh cold-water fish native to China - have become an invasive pest in parts of Australia. Goldfish breeds vary greatly in size, body shape, fin configuration and coloration.",
"Cost": 10,
"icon": preload("res://Gold_fish1.jpg")
}
}
var inventory = {
0: {
"Name": "Baggy",
"Des": "Start here brokie!",
"Cost": 5,
"icon": preload("res://562b27c8-54ea-49fe-9ae5-2f7052fe8b55.png"),
"Count": 1,
}
}
Iteminfo script:
extends CanvasLayer
signal item_changed_globally(new_index)
var ItemName = ""
var ItemDes = ""
var ItemCost = 0
var ItemCount = 0
var CurrItem = 0
var select = 0
var current_selected_index : int = 0
func _process(_delta):
pass
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func updateInfo():
get_node("title").text = ItemName
get_node("des").text = ItemDes + "\nCost" + str(ItemCost)
current_selected_index = CurrItem
func _on_use_pressed() -> void:
for i in Global.inventory:
if Global.inventory[i]["Name"] == ItemName:
print("Emitting Index: ", i)
Global.item_changed_globally.emit(i)
ItemCount -=1
if ItemCount == 0:
var tempDic = {}
for x in Global.inventory:
if x > i:
tempDic[x-1] = Global.inventory[x]
elif x < i:
tempDic[x] = Global.inventory[x]
Global.inventory.clear()
Global.inventory = tempDic
_on_close_pressed()
else:
Global.inventory[i]["Count"] -=1
get_node("../inventorycontainer").fillInventorySlots()
func _on_close_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/inventory.tscn")
And finally Inventorygrid container script:
extends GridContainer
@onready var item = preload("res://scenes/slot.tscn")
var invSize = 24
func _ready():
#load slots in
for i in invSize:
var ItemTemp = item.instantiate()
add_child(ItemTemp)
fillInventorySlots()
func fillInventorySlots():
for i in invSize:
get_child(i).ItemName = ""
get_child(i).ItemDes = ""
get_child(i).ItemCost = 0
get_child(i).ItemCount = 0
get_child(i).hasItem = false
#fills in inventory == slots
for i in Global.inventory:
get_child(i).ItemName = Global.inventory[i]["Name"]
get_child(i).ItemDes = Global.inventory[i]["Des"]
get_child(i).ItemCost = Global.inventory[i]["Cost"]
get_child(i).ItemCount = Global.inventory[i]["Count"]
get_child(i).get_node("count").text = str(Global.inventory[i]["Count"])
get_child(i).get_node("icon").texture = Global.inventory[i]["icon"]
get_child(i).hasItem = true
```



