--[[ A simple inventory that holds 1 item ]] --local itm = nrequire("item.lua") --local ste = nrequire("utility/stream.lua") local inventory = nrequire("inventory/inventory.lua") --local col = nrequire("config/colortheme.lua") local inv = {} if CLIENT then inv = nrequire("cl_skills.lua") end inv.allskills = { ["forageing"] = { "hunting", "butchering", "woodcutting", "plant identification", "archery", }, ["farming"] = { "domestication", "sowing", "arboriculture", "apiarism", "reaping", }, ["artisanship"] = { "pottery", "glass blowing", "cooking", "tanning", "tailoring", "metalworking", "lockpicking", "herbalism", "alchemy", "jewlery", "fletching", "carpentry", }, ["culture"] = { "litteracy", "writeing", "speech", "negotiation", "painting", "performing", "faith", }, ["adventuring"] = { "evasion", "traveling", "lockpicking", "willpower", "dexterity", "sailing", }, ["fighting"] = { "polearm", "axeplay", "two-handed", "sword & shield", "light armor", "heavy armor", "knifeing", "fenceing", "throwing", "archery", } } inv.Name = "Skills" inv.skills = {} for k,v in pairs(inv.allskills) do for i,j in pairs(v) do inv.skills[j] = 0 end end --[[ item should be { name = "name", ammt = 12.3, isskill = True } ]] inv.FindPlaceFor = function(self, item) if item.isskill == nil then return nil end if self.skills[item.name] then return {item.name} else return nil end end inv.CanFitIn = function(self,position,item) return self.skills[position[1]] != nil end inv.Put = function(self,position,item) self.skills[position[1]] = self.skills[position[1]] + item.ammt end inv.Has = function(self,string_or_compare_func) local socf = string_or_compare_func if type(socf) == "string" and self.skills[socf] then return self.skills[socf] elseif type(socf) == "function" then for k,v in pairs(self.skills) do if socf(v) then return k end end else return nil end end inv.Remove = function(self,position) error("Tried to call remove on skill inventory") end inv.Get = function(self,position) return self.skills[position[1]] end inv.Serialize = function(self) return util.TableToJSON(self.skills) end inv.DeSerialize = function(self,data) if data == nil or data == '' then return table.Copy(self) end local cpy = table.Copy(self) cpy.skills = util.JSONToTable(data) return cpy end inventory.RegisterInventory(inv)