Skip to content
Syyrion edited this page Feb 19, 2022 · 5 revisions

A description of every timer type class.

Timers are objects that run functions at precice points in time.

Delay Timer

The Delay Timer runs a function after a set delay. (The timer's delay is still referred to as the period.)

Functions

  • TimerDelay:new(delay, fn, t, noInstantRun)
    Creates a new timer with delay <delay>, function <fn> and timescale <t>. If <noInstantRun> is true, the timer will wait for the next execution of TimerDelay:newDelay(p) before running.

  • TimerDelay:newDelay(delay)
    Starts the timer with delay <delay> in seconds. This function runs TimerDelay:setPeriod(p) with <delay> before starting the timer.

  • TimerDelay:stop()
    Stops the currently running delay operation.

  • TimerDelay:setPeriod(p)
    Sets the delay in seconds. The delay (period) of this timer is allowed to be zero.

  • TimerDelay:getPeriod()
    Gets the delay.

  • TimerDelay:setFunction(fn)
    Sets the function.

  • TimerDelay:getFunction()
    Gets the function.

  • TimerDelay:setTimescale(t)
    Sets the timescale.

  • TimerDelay:getTimescale()
    Gets the timescale.

  • TimerDelay:step(mFrameTime, ...)
    Advances the timer and runs the function when necessary.

Periodic Timer

The Periodic Timer runs a function at set intervals.

Functions

  • TimerPeriodic:new(p, fn, noInstantRun, t)
    Creates a new timer with period <p>, function <fn> and timescale <t>. If <noInstantRun> is true, the first execution of the function is skipped.

  • TimerPeriodic:reset(noInstantRun)
    Restarts the timer. If <noInstantRun> is true, the first execution of the function is skipped.

  • TimerPeriodic:setPeriod(p)
    Sets the period in seconds.

  • TimerPeriodic:getPeriod()
    Gets the period.

  • TimerPeriodic:setFunction(fn)
    Sets the function.

  • TimerPeriodic:getFunction()
    Gets the function.

  • TimerPeriodic:setTimescale(t)
    Sets the timescale.

  • TimerPeriodic:getTimescale()
    Gets the timescale.

  • TimerPeriodic:step(mFrameTime, ...)
    Advances the timer and runs the function when necessary.

Rate Timer

The Rate Timer is similar to a Periodic Timer. It is used to modify the tick rate of a level. Its period set using hertz instead of seconds.

Functions

  • TimerRate:new(hz, fn)
    Creates a new timer with frequency <hz> and function <fn>.

  • TimerRate:setRate(hz)
    Sets the frequency in hertz. Defaults to 240. The frequency must be greater than zero.

  • TimerRate:getRate()
    Gets the frequency.

  • TimerRate:setFunction(fn)
    Sets the function.

  • TimerRate:getFunction()
    Gets the function.

  • TimerRate:step(mFrameTime, ...)
    Advances the timer and runs the function when necessary.

Clone this wiki locally