I want to create some form of factory that allows me to create Item tables very easily. If anyone could help me with this, give me some knowledge about this, I would highly appreciate it.
I'm going for something like
[CODE]Items = {
["playermodel1"] = {Name = "Model1", ClassName = "somemodelpath", Description = "This is model 1", Callback = function(ply) ply:SetModel("somemodelpath") end},
["weapon1"] = {Name = "Weapon1", ClassName = "someweaponclass", Description = "pew", Callback = function(ply) ply:Give("someweaponclass") end },
}[/CODE]
Another potential problem I may run into is storing the inventory, would I just write keys into a table, save it, then use those keys to reference items in the Item table?
[editline]2nd March 2017[/editline]
Also I'd like to apologize for being extremely bad at explaining things. I'm very tired, as always.
If you want to easily create item tables, just make a function to do so. I'm having a hard time understanding the rest of your post.
[QUOTE=sannys;51898245]If you want to easily create item tables, just make a function to do so. I'm having a hard time understanding the rest of your post.[/QUOTE]
I've actually never done a function like this before, can you whip me up an example?
Using an item table for an inventory, how would I go about saving the inventory, and reading it?
[QUOTE=dannyf127;51898282]I've actually never done a function like this before, can you whip me up an example?
Using an item table for an inventory, how would I go about saving the inventory, and reading it?[/QUOTE]
Something like this.
[lua]local function CreateItem(name, className, description, callback)
return {Name = name, ClassName = className, Description = description, Callback = callback}
end
local newItem = CreateItem("Model1", "somemodelpath", "This is model 1", function(ply) ply:SetModel("somemodelpath") end)
print(newItem.Name)[/lua]
A lot of what goes into an inventory system is just in the way it's designed. I don't know how you are designing it, so I can't say how you would go about saving it and loading it.
Sorry, you need to Log In to post a reply to this thread.