` Hello, everyone. I’m currently trying to make a game, but have a problem. I’ve been trying to make an Inventory GUI, following the MakerTech series of tutorials. I’ve succesfully made the Inventory GUI popup at the push of a button (complete with it pausing the game) and also make the slots be either filled or empty. I also added the code and the nodes so the Inventory items show their 2D Sprite. However, no matter what I do, the Items don’t appear in the slots. What is going on? Here is the code for “slot_ui”. If you need me to elaborate, I will gladly do so.
(I lament if I offend anyone with this post.)
extends Control
signal opened
signal closed
var isopen: bool = false
@onready var inventory: Inventory = preload(“res://inventory/playerInventory.tres”) @onready var slots: Array = $NinePatchRect/GridContainer.get_children()
func _ready():
_update()
func _update():
for i in range(min(inventory.items.size(), slots.size())):
slots[i].update(inventory.items[i])
Seems to me that you’re showing itemSprite when item is null. You should swap your item.visible instructions like this:
if !item:
backgroundSprite.frame = 2
itemSprite.visible = false # <-- here you had 'true' although the item is null
else:
backgroundSprite.frame = 0
itemSprite.visible = true # <-- here you had 'false' although the item is NOT null
itemSprite.texture = item.texture