-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem_group.lua
More file actions
44 lines (35 loc) · 936 Bytes
/
item_group.lua
File metadata and controls
44 lines (35 loc) · 936 Bytes
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 item_group = {
_class = "item_group",
--name = color,
--list = {},
--count = 0,
empty = function(self) return (#self.list == 0) end,
extract = function(self)
if #self.list > 0 then
local instance = self.list[#self.list]
table.remove(self.list)
return instance
end
return false
end,
add = function(self, instance)
if type(instance) == "table" then
table.insert(self.list, instance)
self.count = self.count + 1
end
return false
end
}
setmetatable(item_group,{
__call = function(self, name)
if not name then return nil end
local object = {
name = name,
list = {},
count = 0,
}
setmetatable(object, { __index = item_group })
return object
end
})
return item_group