-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path04_groups.lua
More file actions
executable file
·53 lines (45 loc) · 1.06 KB
/
04_groups.lua
File metadata and controls
executable file
·53 lines (45 loc) · 1.06 KB
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
Group = {}
Group.__index = Group
function Group:byId(id)
local group = DataPool().Groups[id]
if group ~= nil then
return Group:from(group)
end
return nil
end
function Group:create(groupId, name)
local obj = DataPool().Groups:Create(groupId)
obj.Name = name
return Group:from(obj)
end
function Group:getOrCreate(id, name)
local group = Group:byId(id)
if group ~= nil then
return group
end
return Group:create(id, name)
end
function Group:address()
return ToAddr(self.obj)
end
function Group:from(group)
local instance = setmetatable({}, Group)
instance.obj = group
return instance
end
function Group:getName()
return self.obj.Name
end
function Group:findWithTag(tag)
local groups = {}
local allGroups = ObjectList('Group Thru')
for _, group in pairs(allGroups) do
if HasTag(group.Tags, tag) then
table.insert(groups, Group:from(group))
end
end
return groups
end
function Group:setAppearance(appearance)
self.obj.Appearance = appearance.obj
end