dcsex.Timer

A count-up Timer.

Contents

  1. Description
  2. Metamethods
    1. timer:__init(timeout, timefunc)
  3. Methods
    1. timer:started()
    2. timer:start()
    3. timer:stop()
    4. timer:reset(limit)
    5. timer:update()
    6. timer:expired()
    7. timer:remain()
    8. timer:extend(time)

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.