Library timer

Deals with timers.

Functions

adjust( name, delay, reps, func ) Adjusts an existing timer
canCreate() Returns whether a new timer can be created without exceeding the quota.
create( name, delay, reps, func ) Creates a timer
exists( name ) Returns whether the given timer exists.
getCount() Returns the number of timers currently active.
getMax() Returns the maximum permitted number of active timers.
pause( name ) Pauses an existing timer
remove( name ) Removes a timer
repsLeft( name ) Returns the number of repetitions left before the timer is destroyed.
simple( delay, func ) Creates a simple timer, has no name, can't be stopped, paused, or destroyed.
start( name ) Starts an existing timer
stop( name ) Stops an existing timer
timeLeft( name ) Returns the time left before the timer next executes its function.
unpause( name ) Unpauses an existing timer


Functions

timer.adjust( name, delay, reps, func )
Adjusts an existing timer

Environment:

Shared

Parameters:

  • name: The timer name
  • delay: The new delay value to use
  • reps: The new repititions of the timer. 0 = infinte.
  • func: The new function to call when the timer is fired.

Return value:

    (boolean) True if the adjustment succeeded.
timer.canCreate()
Returns whether a new timer can be created without exceeding the quota.

Environment:

Shared
timer.create( name, delay, reps, func )
Creates a timer

Environment:

Shared

Parameters:

  • name: The timer name
  • delay: The time, in seconds, to set the timer to.
  • reps: The repititions of the timer. 0 = infinte.
  • func: The function to call when the timer is fired.
timer.exists( name )
Returns whether the given timer exists.

Environment:

Shared

Parameters:

  • name: Name of the timer to check.

Return value:

    (boolean) True if the timer exists, false otherwise.
timer.getCount()
Returns the number of timers currently active.

Environment:

Shared
timer.getMax()
Returns the maximum permitted number of active timers.

Environment:

Shared
timer.pause( name )
Pauses an existing timer

Environment:

Shared

Parameters:

  • name: The timer name

Return value:

    (boolean) True if the timer exists and was not paused, false otherwise.
timer.remove( name )
Removes a timer

Environment:

Shared

Parameters:

  • name: Timer name
timer.repsLeft( name )
Returns the number of repetitions left before the timer is destroyed.

Environment:

Shared

Parameters:

  • name:

Return value:

    (number) Number of repetitions left.
timer.simple( delay, func )
Creates a simple timer, has no name, can't be stopped, paused, or destroyed.

Environment:

Shared

Parameters:

  • delay: The time, in second, to set the timer to.
  • func: The function to call when the timer is fired.
timer.start( name )
Starts an existing timer

Environment:

Shared

Parameters:

  • name: The timer Name

Return value:

    (boolean) True if the timer exists and was stopped, false otherwise.
timer.stop( name )
Stops an existing timer

Environment:

Shared

Parameters:

  • name: The timer name

Return value:

    (boolean) True if the timer exists and was running, false otherwise.
timer.timeLeft( name )
Returns the time left before the timer next executes its function.

Environment:

Shared

Parameters:

  • name:

Return value:

    (number) Time in seconds until the timer next executes.
timer.unpause( name )
Unpauses an existing timer

Environment:

Shared

Parameters:

  • name: The timer name

Return value:

    (boolean) True if the timer exists and was paused, false otherwise.

Valid XHTML 1.0!