-
Notifications
You must be signed in to change notification settings - Fork 23
Timer Library
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.
Timer callbacks receive the timer object as an argument. You can either use the Shine.Timer/Plugin functions to manipulate timers by name, or you can store the timer object returned by the timer creation functions and use them as objects.
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.
Shine.Timer.Simple( 1, function( Timer )
Shared.Message( "Hello there, it's been 1 second since you asked me to run!" )
end )
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.
local Time = 10
Shine.Timer.Create( "10 Second Count", 1, 10, function( Timer )
Shared.Message( tostring( Time ) )
Time = Time - 1
end )
Shine.Timer.Pause( string UniqueID )
Pauses the timer with the given ID.
Shine.Timer.Resume( string UniqueID )
Resumes the timer with the given ID if it was paused.
Shine.Timer.Destroy( string UniqueID )
Halts the given timer and removes it.
Shine.Timer.Exists( string UniqueID )
Returns whether a timer with the given unique ID exists.