forked from modhunter/NerdPack-Protected
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
78 lines (68 loc) · 1.76 KB
/
core.lua
File metadata and controls
78 lines (68 loc) · 1.76 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
local n_name, gbl = ...
local NeP = _G.NeP
local noop = function() end
gbl.version = 2.0
gbl.unlocked = false
local unlockers = {}
gbl.gapis = NeP._G
NeP.Listener:Add(n_name, "ADDON_ACTION_FORBIDDEN", function(...)
local addon = ...
if addon == n_name then
_G.StaticPopup1:Hide()
NeP.Core:Print('Didn\'t find any unlocker, using facerool.',
'\n-> Right click the |cffff0000MasterToggle|r and press |cffff0000'..n_name..' v:'..gbl.version..'|r to try again.')
end
end)
function gbl.AddUnlocker(_, name, eval)
table.insert(unlockers, {
name = name,
test = eval.test,
functions = eval.functions or {},
extended = eval.extended or {},
om = eval.om;
init = eval.init or noop,
prio = eval.prio or 0
})
table.sort( unlockers, function(a,b) return a.prio > b.prio end )
end
function gbl.SetUnlocker(_, name, unlocker)
NeP.Core:Print('|cffff0000Found:|r ' .. name)
unlocker.init()
gbl.MergeTable(unlocker.functions, NeP.Protected)
end
local _loads = NeP.Protected.callbacks
function gbl.TryLoads()
for i=1, #_loads do
if _loads[i] and _loads[i]() then
_loads[i] = nil
end
end
end
function gbl.loadGlobals()
for name, func in pairs(_G) do
NeP._G[name] = func
end
end
function gbl.FindUnlocker()
for i=1, #unlockers do
local unlocker = unlockers[i]
if unlocker.test() then
NeP.Unlocked = nil -- this is created by the generic unlocker (get rid of it)
gbl.loadGlobals()
gbl:SetUnlocker(unlocker.name, unlocker)
gbl.TryLoads()
return true
end
end
end
function gbl.MergeTable(a,b)
for name, func in pairs(a) do
b[name] = func
end
return b
end
NeP.Interface:Add(n_name..' v:'..gbl.version, gbl.FindUnlocker)
-- Delay until everything is ready
NeP.Core:WhenInGame(function()
_G.C_Timer.After(1, gbl.FindUnlocker)
end)