Sooo, i was just setting this, and it works like a charm in-editor, but the second i run it ingame all item quantities go to zero, i figured it was because the quantity is set to zero if the item data does not have the name i put in the inspector, but i mean, that IS what should happen, but it appears that when I run the game, the quantity is set before the name making it to be set to zero, and i have no idea for fixing it.(Awkple and Beshrie are the only items in ItemData, and sorry for the long message...)
extends Resource
class_name ItemStack
@export var item_name : String:
set(value):
item_name = value
if ItemData.item_data.has(item_name):
item_quantity = clamp(item_quantity, 0, ItemData.item_data[item_name]["StackSize"])
else:
push_warning("Item name is not any item in the game!")
item_quantity = 0
@export var item_quantity : int :
set(value):
item_quantity = value
if ItemData.item_data.has(item_name):
item_quantity = clamp(value, 0, ItemData.item_data[item_name]["StackSize"])
else:
item_quantity = 0
func isEmpty() -> bool:
return item_quantity == 0```
That console image is what happens when i print in a for loop, the item name and quantity after
i have 3 slots but the update is called twice at the start, thats why they repeat