-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompatability.lua
66 lines (59 loc) · 1.54 KB
/
Compatability.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
54
55
56
57
58
59
60
61
62
63
64
65
66
if not strsplit then
function strsplit(delimiter, text)
local result = {}
local from = 1
local delim_from, delim_to = string.find(text, delimiter, from)
while delim_from do
table.insert(result, string.sub(text, from, delim_from - 1))
from = delim_to + 1
delim_from, delim_to = string.find(text, delimiter, from)
end
table.insert(result, string.sub(text, from))
return unpack(result)
end
end
if not string.match then
local function getargs(s, e, ...)
return unpack(arg)
end
function string.match(str, pattern)
if not str then str = "" end
return getargs(string.find(str, pattern))
end
end
if not string.trim then
function string.trim(str)
return (string.match(str, "^%s*(.-)%s*$"))
end
end
if not table.wipe then
function table.wipe(tbl)
for key in next, tbl do
tbl[key] = nil
end
end
end
if not wipe then
wipe = table.wipe
end
if not hooksecurefunc then
---@overload fun(name, hook)
function hooksecurefunc(table, name, hook)
if not hook then
name, hook = table, name
table = _G
end
local old = table[name]
assert(type(old) == "function")
table[name] = function(...)
local result = { old(unpack(arg)) }
hook(unpack(arg))
return unpack(result)
end
end
end
if not print then
function print(msg)
DEFAULT_CHAT_FRAME:AddMessage(msg)
end
end