1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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)
|