-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Core.lua
79 lines (65 loc) · 2.52 KB
/
Core.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
75
76
77
78
79
HelloWorld = CreateFrame("Frame")
function HelloWorld:OnEvent(event, ...)
self[event](self, event, ...)
end
HelloWorld:SetScript("OnEvent", HelloWorld.OnEvent)
HelloWorld:RegisterEvent("ADDON_LOADED")
function HelloWorld:ADDON_LOADED(event, addOnName)
if addOnName == "HelloWorld" then
HelloWorldDB = HelloWorldDB or {}
self.db = HelloWorldDB
for k, v in pairs(self.defaults) do
if self.db[k] == nil then
self.db[k] = v
end
end
self.db.sessions = self.db.sessions + 1
print("You loaded this addon "..self.db.sessions.." times")
local version, build, _, tocversion = GetBuildInfo()
print(format("The current WoW build is %s (%d) and TOC is %d", version, build, tocversion))
self:RegisterEvent("PLAYER_ENTERING_WORLD")
hooksecurefunc("JumpOrAscendStart", self.JumpOrAscendStart)
self:InitializeOptions()
self:UnregisterEvent(event)
end
end
function HelloWorld:PLAYER_ENTERING_WORLD(event, isLogin, isReload)
if isLogin and self.db.hello then
DoEmote("HELLO")
end
end
-- note we don't pass `self` here because of hooksecurefunc, hence the dot instead of colon
function HelloWorld.JumpOrAscendStart()
if HelloWorld.db.jump then
print("Your character jumped.")
end
end
function HelloWorld:COMBAT_LOG_EVENT_UNFILTERED(event)
-- it's more convenient to work with the CLEU params as a vararg
self:CLEU(CombatLogGetCurrentEventInfo())
end
local playerGUID = UnitGUID("player")
local MSG_DAMAGE = "Your %s hit %s for %d damage."
function HelloWorld:CLEU(...)
local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
local spellId, spellName, spellSchool
local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand
local isDamageEvent
if subevent == "SWING_DAMAGE" then
amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand = select(12, ...)
isDamageEvent = true
elseif subevent == "SPELL_DAMAGE" then
spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand = select(12, ...)
isDamageEvent = true
end
if isDamageEvent and sourceGUID == playerGUID then
-- get the link of the spell or the MELEE globalstring
local action = spellId and GetSpellLink(spellId) or MELEE
print(MSG_DAMAGE:format(action, destName, amount))
end
end
SLASH_HELLOW1 = "/hw"
SLASH_HELLOW2 = "/helloworld"
SlashCmdList.HELLOW = function(msg, editBox)
Settings.OpenToCategory(HelloWorld.panel_main.name)
end