Closed RobertSzaszak closed 1 year ago
I could prevent crashing by using the following code:
func UpdateButton(index : int):
if gridContainer.get_child(index) == null:
print("Error: Child at index " + str(index) + " is null")
return
if range(items.size()).has(index):
gridContainer.get_child(index).UpdateItem(items[index], index)
else:
gridContainer.get_child(index).UpdateItem(null, index)
I also changed the function button function:
func _on_button_button_down() -> void:
var item = ResourceLoader.load("res://Resources/Test_Item.tres")
if items.size() < gridContainer.get_child_count():
Add(item)
else:
print("Error: Grid container is full")
pass
This issue has been fixed!
If you add more items to the inventory than its capacity by using the Add Item button you get the following error: