Thread Tools Display Modes
11-19-12, 07:55 PM   #1
Wowguy25
A Deviate Faerie Dragon
Join Date: Nov 2012
Posts: 17
Return true after X seconds?

How would I make a function like this?
  Reply With Quote
11-19-12, 09:34 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Option #1
Code:
local f,delay=CreateFrame("frame"),10
f.OnUpdate = function(self,elapsed)
  self.lastupdate = (self.lastupdate or 0)+elapsed
  if self.lastupdate >= delay then -- 10 seconds passed
    self.lastupdate=0
    -- do something
    f:Hide() -- comment out if you want a repeating timer
  end
end
f:SetScript("OnUpdate",f.OnUpdate)
Option #2
Code:
local f,delay=CreateFrame("frame"),10
f.OnFinished = function(self,requested)
  -- 10 seconds passed, do stuff
    -- f.ag:Play() -- uncomment if you want a repeating timer
end
f.ag = f:CreateAnimationGroup()
f.ag.timer = f.ag:CreateAnimation("Animation")
f.ag.timer:SetScript("OnFinished",f.OnFinished)
f.ag.timer:SetDuration(delay)
f.ag:SetLooping("NONE")
f.ag:Play()

Last edited by Dridzt : 05-08-13 at 09:35 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Return true after X seconds?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off