jwilson56
November 15th, 2008, 05:39 PM
Well one function I use a lot is a delay timer. Nice thing is it will not hold up anything waiting around for a delay. Basic structure I use is as follows:
-- myDED and delayedFunc are any names you want
local function delayedFunc ()
-- This function will execute 60 seconds after so
-- do what you want after the delay here
end
-- do what you want before the delay here
Voice:Speak('This will play first and then after 60 seconds the other function will run')
-- kills any current delay timer... basically resets the delay
if myDED then -- kills an existing dispatcher
myDED:Close ()
myDED = nil
end
-- time is milliseconds so this would be 1 minute
-- setup new delay function. It will execute the 'delayedFunc' in 60 seconds
myDED = Classes.DelayedExecutionDispatcher:New (60000,delayedFunc)
-- myDED and delayedFunc are any names you want
local function delayedFunc ()
-- This function will execute 60 seconds after so
-- do what you want after the delay here
end
-- do what you want before the delay here
Voice:Speak('This will play first and then after 60 seconds the other function will run')
-- kills any current delay timer... basically resets the delay
if myDED then -- kills an existing dispatcher
myDED:Close ()
myDED = nil
end
-- time is milliseconds so this would be 1 minute
-- setup new delay function. It will execute the 'delayedFunc' in 60 seconds
myDED = Classes.DelayedExecutionDispatcher:New (60000,delayedFunc)