Mercurial > wow > reagentmaker
diff CampFireButton.lua @ 103:c8d527a9fb3a v1.0beta11
Better manage combat and secure buttons
author | contrebasse |
---|---|
date | Sat, 21 May 2011 14:19:33 +0200 |
parents | 060f5d0f7a35 |
children | 08ede537787b |
line wrap: on
line diff
--- a/CampFireButton.lua Fri May 20 23:28:41 2011 +0200 +++ b/CampFireButton.lua Sat May 21 14:19:33 2011 +0200 @@ -7,6 +7,8 @@ -- Create button function A.InitialiseCampFireBtn() + if not GetTradeSkillLine() or InCombatLockdown() then return end + -- create the frame btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate") btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID))) @@ -32,9 +34,6 @@ local GetSpellCooldown = GetSpellCooldown btn:SetScript("OnUpdate",function(self) CooldownFrame_SetTimer(self.cooldown,GetSpellCooldown(CAMPFIRE_ID)); end) - -- Save info - cookingName = GetSpellInfo(COOKING_ID) - -- Show if needed A.ManageCampFireBtn() end @@ -46,12 +45,17 @@ -- Show button if applicable function A.ManageCampFireBtn() - if not btn then return end -- Display only if the tradeskill is Cooking - local tradeskillName = GetTradeSkillLine() - if tradeskillName ~= cookingName then - btn:Hide() + if not cookingName then cookingName = GetSpellInfo(COOKING_ID) end + if GetTradeSkillLine() ~= cookingName then + if btn then btn:Hide() end else + -- create button if necessary + if not btn then + A.InitialiseCampFireBtn() + end + -- It may not have been created + if not btn then return end btn:Show() end end