What do you all think would be going about the best way to make an inventory system? I am attempting currently to take the names of any item i pick up and associate that with a value in a slot on my players inventory ui. with a stack value so i can pick up multiples of any item while only using one slot so long as its the same item. I know its not a great method perhaps but it's what I've got so far. I just want to know if I need to rewrite it now to make it easier on saving to data stores. I'm not sure how inefficient this is. and if there IS a better method, could someone please provide a sort of example?
✓ ANSWER ACCEPTED
Scripting method on inventory systems?
1 answer
✓ Accepted answer
First thing that came to mind,
You could make a dictionary containing indexes that correspond to each slot in a players inventory:
local inventory = {
[1] = "Sword";
[2] = "Shield";
[3] = false;
[4] = "Health Potion";
[5] = "Damage Potion";
}
--[[
The following is just another example on how this method could be useful.
You can easily change the values of a players inventory. When the player picks up
a new weapon, you just change the corresponding index.
Or
When they go to use an ability you can easily check the cooldown on that ability
]]
local abilities = {
[1] = {"Fireball", 0} -- argument 2 would be a cooldown value.
[2] = {"Invisibility, 0.322}
}
Hopefully this helped you out. If I come up with any other ideas ill make sure to edit them in.
This discussion is preserved as it was. New answers, comments, and votes are closed.
