From f3776e8c1708f3cbe64dbf96556be07ed8e33e97 Mon Sep 17 00:00:00 2001 From: p3lim Date: Thu, 14 Oct 2010 19:54:25 +0200 Subject: [PATCH] Register the tags outside of the Enable function --- oUF_Experience.lua | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/oUF_Experience.lua b/oUF_Experience.lua index 5f3559c..a6f0a93 100644 --- a/oUF_Experience.lua +++ b/oUF_Experience.lua @@ -2,7 +2,7 @@ local _, ns = ... local oUF = ns.oUF or oUF assert(oUF, 'oUF Experience was unable to locate oUF install') -local tagStrings = { +for tag, func in pairs({ ['curxp'] = function(unit) if(unit == 'pet') then return GetPetExperience() @@ -26,7 +26,7 @@ local tagStrings = { return math.floor(UnitXP(unit) / UnitXPMax(unit) * 100 + 0.5) end end, - ['currested'] = function(unit) + ['currested'] = function() return GetXPExhaustion() end, ['perrested'] = function(unit) @@ -35,15 +35,10 @@ local tagStrings = { return math.floor(rested / UnitXPMax(unit) * 100 + 0.5) end end, -} - -local tagEvents = { - ['curxp'] = 'PLAYER_XP_UPDATE PLAYER_LEVEL_UP UNIT_PET_EXPERIENCE', - ['maxxp'] = 'PLAYER_XP_UPDATE PLAYER_LEVEL_UP UNIT_PET_EXPERIENCE', - ['perxp'] = 'PLAYER_XP_UPDATE PLAYER_LEVEL_UP UNIT_PET_EXPERIENCE', - ['currested'] = 'UPDATE_EXHAUSTION', - ['perrested'] = 'UPDATE_EXHAUSTION', -} +}) do + oUF.Tags[tag] = func + oUF.TagEvents[tag] = 'PLAYER_XP_UPDATE PLAYER_LEVEL_UP UNIT_PET_EXPERIENCE UPDATE_EXHAUSTION' +end local function Unbeneficial(self, unit) if(unit == 'player') then @@ -111,14 +106,6 @@ local function Enable(self) self:RegisterEvent('PLAYER_LEVEL_UP', Path) self:RegisterEvent('UNIT_PET_EXPERIENCE', Path) - for tag, func in pairs(tagStrings) do - oUF.Tags[tag] = func - end - - for tag, event in pairs(tagEvents) do - oUF.TagEvents[tag] = event - end - local rested = experience.Rested if(rested) then self:RegisterEvent('UPDATE_EXHAUSTION', Path) -- 1.7.9.5