-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup.lua
More file actions
51 lines (44 loc) · 1.35 KB
/
Copy pathSetup.lua
File metadata and controls
51 lines (44 loc) · 1.35 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
local appName, app = ...;
app.CHARACTER_DATA = {};
app.ALTS = {};
-- helper code for event handlers
local frame = CreateFrame("Frame");
local handlers = {};
function app:OnEvent(event, fn)
if not handlers[event] then
handlers[event] = {};
frame:RegisterEvent(event);
end
table.insert(handlers[event], fn);
end
frame:SetScript("OnEvent", function(self, event, ...)
if handlers[event] then
for _, handler in ipairs(handlers[event]) do
handler(...)
end
end
end)
-- initialization
app:OnEvent("PLAYER_LOGIN", function(...)
-- Determines the player's region and loads that data
local region = GetCVar('portal');
local fn = app["Load" .. region];
if fn then
print("Data for Azeroth: Loading data for " .. region);
fn();
else
-- TODO what should we do if the CVar doesn't work right?
print("Data for Azeroth: Could not find player's region " .. region);
end
local myguid = UnitGUID("player");
if myguid and not issecretvalue(myguid) then
-- If the current character is found, track it as main in a saved variable
if app.CHARACTER_DATA[myguid:gsub("Player%-", "")] then
DFA_MAIN = myguid;
end
-- setup alts lookup table
if DFA_MAIN then
app.ALTS[myguid] = DFA_MAIN;
end
end
end)