* Added `StartIf()`
This commit is contained in:
Applevangelist 2023-01-01 12:33:35 +01:00
parent 144521936a
commit 6fa3f0a11c

View File

@ -155,7 +155,7 @@ function TIMER:New(Function, ...)
return self return self
end end
--- Create a new TIMER object. --- Start TIMER object.
-- @param #TIMER self -- @param #TIMER self
-- @param #number Tstart Relative start time in seconds. -- @param #number Tstart Relative start time in seconds.
-- @param #number dT Interval between function calls in seconds. If not specified `nil`, the function is called only once. -- @param #number dT Interval between function calls in seconds. If not specified `nil`, the function is called only once.
@ -192,6 +192,20 @@ function TIMER:Start(Tstart, dT, Duration)
return self return self
end end
--- Start TIMER object if a condition is met. Useful for e.g. debugging.
-- @param #TIMER self
-- @param #boolean Condition Must be true for the TIMER to start
-- @param #number Tstart Relative start time in seconds.
-- @param #number dT Interval between function calls in seconds. If not specified `nil`, the function is called only once.
-- @param #number Duration Time in seconds for how long the timer is running. If not specified `nil`, the timer runs forever or until stopped manually by the `TIMER:Stop()` function.
-- @return #TIMER self
function TIMER:StartIf(Condition,Tstart, dT, Duration)
if Condition then
self:Start(Tstart, dT, Duration)
end
return self
end
--- Stop the timer by removing the timer function. --- Stop the timer by removing the timer function.
-- @param #TIMER self -- @param #TIMER self
-- @param #number Delay (Optional) Delay in seconds, before the timer is stopped. -- @param #number Delay (Optional) Delay in seconds, before the timer is stopped.