Repository navigation
Expand file tree
/
Copy pathList.lua
More file actions
167 lines (121 loc) · 2.68 KB
/
Copy pathList.lua
File metadata and controls
167 lines (121 loc) · 2.68 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
local BPCM = select(2, ...)
BPCM.List = {
Table = {},
Title = "Generic List",
TitleColor = "FFFFFFFF"
};
local List = BPCM.List
local Table = {};
function List:new (o)
o = o or { Table = {} };
local obj = setmetatable(o, List);
self.__index = self;
self:SetTable(o.Table);
return o;
end
function List:TableCount(theTable)
local count = 0;
for index, value in pairs(theTable) do
count = count + 1;
end
return count;
end
function List:GetTitle()
return "|c"..tostring(self.TitleColor)..tostring(self.Title).."|r";
end
function List:Print(text)
print(self:GetTitle()..tostring(text));
end
function List:Count()
return List:TableCount(self:GetTable());
end
function List:Set(item, value)
local table = self:GetTable();
table[item] = value;
self:SetTable(table);
end
function List:Clear()
self:SetTable({});
end
function List:FindIndex(indexToFind)
if not indexToFind then
return;
end
for index, value in pairs(self:GetTable()) do
indexLowered = index:gsub("%*", "%.%*"):lower();
indexToFindLowered = indexToFind:lower();
if indexLowered == indexToFindLowered or indexToFindLowered:find("^"..indexLowered.."$") then
return index;
end
end
end
function List:FindIndexByValue(valueToFind)
for index, value in pairs(self:GetTable()) do
if value == valueToFind then
return index;
end
end
end
function List:Contains(item)
return self:FindIndex(item) ~= nil;
end
function List:Populate(items)
local table = {};
for index, item in pairs(items) do
if item ~= "" then
table[item] = List:TableCount(table) + 1;
end
end
self:SetTable(table);
self:Print(" updated.");
end
function List:ToString()
local list = "";
for index = 0, self:Count() do
local item = self:FindIndexByValue(index);
if item ~= nil then
list = list..item.."\n";
end
end
return list;
end
function List:GetTable()
return Table;
end
function List:SetTable(value)
Table = value;
end
BPCM.PetBlacklist = List:new {
Title = "Pet Blacklist",
TitleColor = "FFA9A9A9";
}
local PetBlacklist = BPCM.PetBlacklist
function PetBlacklist:new (o)
o = o or {};
setmetatable(o, PetBlacklist);
self.__index = self;
return o;
end
function PetBlacklist:GetTable()
return BPCM.Profile.Pet_Blacklist;
end
function PetBlacklist:SetTable(value)
BPCM.Profile.Pet_Blacklist = value;
end
BPCM.PetWhitelist = List:new {
Title = "Pet Whitelist",
TitleColor = "FFA9A9A9";
}
local PetWhitelist = BPCM.PetWhitelist
function PetWhitelist:new (o)
o = o or {};
setmetatable(o, PetWhitelist);
self.__index = self;
return o;
end
function PetWhitelist:GetTable()
return BPCM.Profile.Pet_Whitelist;
end
function PetWhitelist:SetTable(value)
BPCM.Profile.Pet_Whitelist = value;
end