aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/skills/sh_skills.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/inventorysystem/skills/sh_skills.lua')
-rw-r--r--gamemode/inventorysystem/skills/sh_skills.lua140
1 files changed, 140 insertions, 0 deletions
diff --git a/gamemode/inventorysystem/skills/sh_skills.lua b/gamemode/inventorysystem/skills/sh_skills.lua
new file mode 100644
index 0000000..27c3bad
--- /dev/null
+++ b/gamemode/inventorysystem/skills/sh_skills.lua
@@ -0,0 +1,140 @@
+--[[
+ 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)