From 6977cb18852d811dca3862b02a4325705fe94d76 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Fri, 30 Apr 2010 15:18:39 +0200 Subject: [PATCH] Use a fail-check instead of delaying event registration --- Spequip.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Spequip.lua b/Spequip.lua index 286e5c4..f05abfa 100644 --- a/Spequip.lua +++ b/Spequip.lua @@ -1,4 +1,8 @@ -local function OnEvent() +local Spequip = CreateFrame('Frame') +Spequip:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED') +Spequip:SetScript('OnEvent', function() + if(not GetNumTalentTabs()) then return end + local talentIndex local mostPoints = -1 local mostPointsName @@ -21,12 +25,4 @@ local function OnEvent() end print('|cffff8080Spequip:|r Unable to match equipment set to', mostPointsName, '(' .. talentString .. ')') -end - -local Spequip = CreateFrame('Frame') -Spequip:RegisterEvent('PLAYER_LOGIN') -Spequip:SetScript('OnEvent', function(self, event) - self:UnregisterEvent(event) - self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED') - self:SetScript('OnEvent', OnEvent) end) -- 1.7.9.5