From cd04a77c537a6539899fb9a4febe9b52b88a33b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Nov 2009 21:00:00 +0100 Subject: [PATCH] Secure against combat bugs --- Molinari.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Molinari.lua b/Molinari.lua index 6709089..933e57e 100644 --- a/Molinari.lua +++ b/Molinari.lua @@ -7,7 +7,13 @@ button:SetBackdropColor(1, 0.5, 0.5, 0.4) button:RegisterEvent('MODIFIER_STATE_CHANGED') button:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end) -button:SetScript('OnLeave', function(self) self:Hide() end) +button:SetScript('OnLeave', function(self) + if(InCombatLockdown()) then + self:RegisterEvent('PLAYER_REGEN_ENABLED') + else + self:Hide() + end +end) local macro = '/cast %s\n/use %s %s' local spell = GetSpellInfo(51005) @@ -18,8 +24,13 @@ function button:MODIFIER_STATE_CHANGED(event, key) end end +function button:PLAYER_REGEN_ENABLED(event) + self:UnregisterEvent(event) + self:Hide() +end + GameTooltip:HookScript('OnTooltipSetItem', function(self) - if(self:GetItem() and IsAltKeyDown()) then + if(self:GetItem() and IsAltKeyDown() and not InCombatLockdown()) then if(GameTooltipTextLeft2:GetText() == ITEM_MILLABLE) then button:SetAttribute('macrotext', macro:format(spell, GetMouseFocus():GetParent():GetID(), GetMouseFocus():GetID())) -- 1.7.9.5