# HG changeset patch # User contrebasse # Date 1291995420 -3600 # Node ID 47f9e596ef5a71544d88137a6c615312eea5782a # Parent f8198806d261bd586d9aae30e358e0d40a6b8de7 Use a specific function for drawing diff -r f8198806d261 -r 47f9e596ef5a Degaine.lua --- a/Degaine.lua Fri Dec 10 16:20:57 2010 +0100 +++ b/Degaine.lua Fri Dec 10 16:37:00 2010 +0100 @@ -27,6 +27,18 @@ --------------------------------------------------------------- +-- Local vars +--------------------------------------------------------------- +-- const +local DegaineFrame = CreateFrame("Frame") +local playername = UnitName("player") + +-- vars +local done = true +local t_left = -1 +local delay = 2 -- seconds + +--------------------------------------------------------------- -- Some stuff... --------------------------------------------------------------- -- Bindings @@ -39,17 +51,6 @@ --------------------------------------------------------------- --- Local vars ---------------------------------------------------------------- --- const -local DegaineFrame = CreateFrame("Frame") -local playername = UnitName("player") - --- vars -local done = true -local t_left = -1 - ---------------------------------------------------------------- -- Events config --------------------------------------------------------------- -- Events to watch @@ -76,7 +77,7 @@ --------------------------------------------------------------- --- Timer +-- Launch drawing weapons --------------------------------------------------------------- -- Wait a few seconds before drawing, to be able to see the curren animation (and avoid bugs) local Degaine_OnUpdate = function(self,t_elapsed) @@ -85,10 +86,17 @@ if t_left<=0 then done = true; ToggleSheath(); + DegaineFrame:SetScript("OnUpdate", nil); end end end - +local start = function() + if Degaine_isAuto and not InCombatLockdown() then + t_left = delay + done = false + DegaineFrame:SetScript("OnUpdate", Degaine_OnUpdate); + end +end --------------------------------------------------------------- -- Activation functions @@ -143,8 +151,7 @@ if ((events[event] and (type(events[event])~="function" or events[event]())) or (events1player[event] and arg1=="player") or (events2playername[event] and arg2==playername)) then - t_left = 2 - done = false + start() elseif event == "PLAYER_REGEN_ENABLED" then desactivate() @@ -155,11 +162,7 @@ if Degaine_isAuto==nil then Degaine_isAuto = true end - if Degaine_isAuto then - activate() - else - desactivate() - end + if Degaine_isAuto then activate(); else desactivate(); end printState() -- Not needed anymore @@ -168,12 +171,7 @@ end -- Hook when standing up -- (Didn't work, see http://forums.wowace.com/showthread.php?p=310547#post310547) -hooksecurefunc("SitStandOrDescendStart",function() - if Degaine_isAuto and not InCombatLockdown() then - t_left = 2 - done = false - end -end) +hooksecurefunc("SitStandOrDescendStart",start); ---------------------------------------------------------------