You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
705 B
26 lines
705 B
|
2 years ago
|
local Addon = LibStub('AceAddon-3.0'):GetAddon('WoWthing_Collector')
|
||
|
|
local Module = Addon:NewModule('XP')
|
||
|
|
|
||
|
|
|
||
|
|
function Module:OnEnable()
|
||
|
|
self:RegisterBucketEvent({ 'PLAYER_UPDATE_RESTING', 'UPDATE_EXHAUSTION' }, 1, 'UpdateRested')
|
||
|
|
self:RegisterBucketEvent({ 'PLAYER_XP_UPDATE' }, 1, 'UpdateXP')
|
||
|
|
end
|
||
|
|
|
||
|
|
function Module:OnEnteringWorld()
|
||
|
|
self:UpdateRested()
|
||
|
|
self:UpdateXP({ player = 1 })
|
||
|
|
end
|
||
|
|
|
||
|
|
function Module:UpdateRested()
|
||
|
|
Addon.charData.isResting = IsResting()
|
||
|
|
Addon.charData.restedXP = GetXPExhaustion() or 0
|
||
|
|
end
|
||
|
|
|
||
|
|
function Module:UpdateXP(units)
|
||
|
|
if units.player then
|
||
|
|
Addon.charData.level = UnitLevel('player')
|
||
|
|
Addon.charData.levelXp = UnitXP('player')
|
||
|
|
end
|
||
|
|
end
|