Ok, so I am trying to make an inventory script that makes items non-stackable and stackable at the same time, in the dictionary I used key for item Name and value for item amount. Now I have a sword, and I don’t want it to stack with the same sword, but instead, it will occupied the new slot. table.insert wont work because it only work in tables, Also you can’t write directly in the dictionary, it must be append
Then just use an array, then use table.insert. You can’t append to dictionary it has no theoretical end. There is no way to add to dictionary using the same key, you will either have to use an array or store a quantity field in the dictionary entry.
I mean I want to do it the way minecraft did it, I am planing to use the quantity field as tool durability, if there is no way, then I will rewrite my inventory system
Minecraft is written in Java (Bedrock in C#, but it boils down to the same concept) and everything in Java is an object since the language forces OOP.
Minecraft stores objects, not their quantities alone. The way it is done is that all items derive from the same class which contains properties for item ID, display name, quantity and many other.
For example:
{
slot1 = {
Name = "sword",
Quantity = 1,
Stackable = false,
Durability = 1,
}
}
yeah, I am planing to store the item like this