Skip to content
Person8880 edited this page Jul 8, 2013 · 3 revisions

Overview

The timer library allows for setting timed callbacks that can be repeated and manipulated.

All timer functions are contained in:

Shine.Timer

Delays are in seconds. Timers are available on both the server and the client.

Shine.Timer.Simple

Shine.Timer.Simple( float Delay, function Callback )

Creates a simple timer, which is essentially a delayed action. Runs only once after the set delay and then removes itself.

Example:

Shine.Timer.Simple( 1, function()
    Shared.Message( "Hello there, it's been 1 second since you asked me to run!" )
end )

Shine.Timer.Create

Shine.Timer.Create( string UniqueID, float Delay, int Reps, function Callback )

Creates a timer that runs for the given number of times (Reps) with the given delay between them. The unique ID lets you track the timer's existence and remove it early if you wish.

Example:

local Time = 10
Shine.Timer.Create( "10 Second Count", 1, 10, function()
    Shared.Message( tostring( Time ) )
    Time = Time - 1
end )

Shine.Timer.Destroy

Shine.Timer.Destroy( string UniqueID )

Halts the given timer and removes it.

Shine.Timer.Exists

Shine.Timer.Exists( string UniqueID )

Returns whether a timer with the given unique ID exists.

Clone this wiki locally