dcsext.Timer
A count-up Timer.
Contents
Description
The timer is not cycle accurate and requires the update method to be called periodically to progress the timer to expiration. Additionally, you must call start method before the timer will actually start counting even if the update method is called.
Metamethods
timer:__init(timeout, timefunc)
Create a Timer instance using timefunc as the timer source and timeout as the number of seconds until the timer expires. The timer source is commonly os.clock to time against wall clock or timer.getAbsTime to get the simulation time step in DCS.
Parameters
- timeout
- [number] how long the timer will count in seconds.
- timefunc
- [function] callback to get the time or defaults to
timer.getAbsTime.
Methods
timer:started()
Returns
- bool, true means timer is started.
timer:start()
timer:stop()
timer:reset(limit)
Parameters
- limit
- reset to new timeout if nil keeps the old timeout length
Returns
- how long the timer had been running in seconds.
timer:update()
timer:expired()
timer:remain()
timer:extend(time)
Parameters
- time
- time in seconds to extend the timeout by.