aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/prayers/sh_prayers.lua
blob: 208540d1abd99ad5a33846b2b9c3c61a7bda287f (plain)
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
local reg = nrequire("inventory.lua")
local itm = nrequire("item.lua")
local inv = {}
inv.Name = "Prayers"
inv.track = {}
function inv:FindPlaceFor(item)
	return {#track}
end
function inv:CanFitIn(pos,item)
	return pos[1] == #self.track
end
function inv:Put(pos,item)
	self.track[pos[1]] = item
end
function inv:Has(a)
	if type(a) == "string" then
		for k,v in pairs(self.track) do
			if v == a then return {k} end
		end
	elseif type(a) == "function" then
		for k,v in pairs(self.track) do
			if a(v) then return {k} end
		end
	end
	return nil
end
function inv:Remove(pos)
	for i = 1,pos[1] do
		self.track[i] = self.track[i+1]
	end
end
function inv:Get(pos)
	return self.track[pos[1]]
end
function inv:Serialize()
	local ret = {}
	for k,v in pairs(self.track) do
		ret[v.Name] = v:Serialize()
	end
end


reg.RegisterInventory(inv)