Mercurial > wow > degaine
changeset 8:47f9e596ef5a
Use a specific function for drawing
author | contrebasse |
---|---|
date | Fri, 10 Dec 2010 16:37:00 +0100 |
parents | f8198806d261 |
children | 571dcc76d801 |
files | Degaine.lua |
diffstat | 1 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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); ---------------------------------------------------------------