-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathghoststart.lua
74 lines (58 loc) · 1.98 KB
/
ghoststart.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
67
68
69
70
71
72
73
74
ghost = {};
function ghost:OnLoad()
SLASH_GHOST1 = "/ghost";
SLASH_GHOSTV1 = "/ghostv";
SLASH_GHOSTV2 = "/gv";
SlashCmdList["GHOST"] = function(msg) ghost:HandleSlashCommand(msg, true) end
SlashCmdList["GHOSTV"] = function(msg) ghost:HandleSlashCommand(msg, false) end
ghostFrame:RegisterEvent("PLAYER_LOGIN")
ghostFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
ghostFrame:RegisterEvent("ADDON_LOADED")
end
function ghost:OnEvent(self, event, ...)
local arg1, arg2, arg3, arg4 = ...
if event == "ADDON_LOADED" and arg1 == "ghost" then
ghostFrame:UnregisterEvent("ADDON_LOADED");
elseif event == "PLAYER_LOGIN" then
ghostFrame:UnregisterEvent("PLAYER_LOGIN");
ghost:LoadQuestData();
ghost:LoadPlayerData();
ghost:LoadAccountData();
ghost:PrimeItemCache();
ghost:UpdatePlayerProgress();
ghost:Announce();
elseif event == "PLAYER_ENTERING_WORLD" then
ghostFrame:UnregisterEvent("PLAYER_ENTERING_WORLD");
end
end
function ghost:LoadPlayerData()
ghost.CurrentRealm = GetRealmName();
ghost.PlayerName = UnitName("player");
ghost.PlayerNameWithRealm = ghost.CurrentRealm.." - "..ghost.PlayerName
ghost.PlayerClass = UnitClass("player");
ghost.PlayerFaction = UnitFactionGroup("player");
ghost.PlayerLevel = UnitLevel("player");
ghost.PlayerProgress = {}
end
function ghost:LoadAccountData()
if(GhostCharacterProgress == nil) then
GhostCharacterProgress = {}
end
if(GhostCharacterProgress[ghost.CurrentRealm] == nil) then
GhostCharacterProgress[ghost.CurrentRealm] = {}
end
end
-- Calls GetItemInfo on all related quest items to prime the local cache
function ghost:PrimeItemCache()
-- Get each chapter
for index, chapter in pairs(ghost.MainQuest.Chapters) do
GetItemInfo(chapter.ItemID)
-- Get pages for each chapter
for index, itemID in pairs(chapter.Pages) do
GetItemInfo(itemID)
end
end
end
function ghost:Announce()
ghost:PrintMessageWithGhostPrefix("activated");
end