View Single Post
10-13-10, 04:52 PM   #5
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
not a problem, sorry for the delay in response as well.

you could simply try

Code:
local lastAlpha = 0
--this is just for proper scoping of this variable, so it saves between function calls
...

function foo()--this is the function where the snippet below is contained

if isEnergize == true and lastAlpha+2<GetTime() then
	_G["RuneButtonIndividual"..runeIndex]:SetAlpha(RHaic)
        lastAlpha = GetTime()
end

end
if isEngerize is true, and the last time we changed the alpha (lastAlpha) is less than 2 seconds ago, then we ignore the function call.

so if we are running through the code

lua Code:
  1. local isEnergize = true
  2. local lastAlpha = 0
  3. GetTime()--outputs 100 in this example, real values will likely be in the 6 digits
  4.  
  5. if isEnergize is true and lastAlpha (which is 0) + 2 (total of 2) is lessthan 100 then do the if statement
  6. set the alpha and now store lastAlpha as 100
  7.  
  8. now the event is called 1 second later
  9.  
  10. if isEnergize is true and lastAlpha(which is 100) + 2 (total of 102) is less than 101 (because it was called one second later, and now GetTime() outputs 101) then do the if statement, however it returns false.
and now your function is no longer called i would set the 2 alot lower, i just wanted to use whole numbers for ease of explaniation... let me know if this isnt clear, I'm bad at explaining things lol
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote