-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlib.lua
53 lines (46 loc) · 952 Bytes
/
lib.lua
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
function IsModChanged(data,modName)
if data
and data.mod_changes
and data.mod_changes[modName]
and data.mod_changes[modName].old_version then
return true
end
return false
end
function GetOldVersion(data,modName)
return FormatVersion(data.mod_changes[modName].old_version)
end
function GetNewVersion(data,modName)
return FormatVersion(data.mod_changes[modName].new_version)
end
function FormatVersion(version)
return string.format("%02d.%02d.%02d", string.match(version, "(%d+).(%d+).(%d+)"))
end
function Contains(tab,elem)
for _,v in pairs(tab) do
if v == elem then
return true
elseif type(v) == "table" then
if Contains(v,elem) then
return true
end
end
end
return false
end
function Remove(tab,elem)
for i,v in pairs(tab) do
if v == elem then
table.remove(tab,i)
return true
end
end
return false
end
function Count(list)
local i = 0
for _ in pairs(list) do
i = i + 1
end
return i
end