forked from Person8880/Shine
-
Notifications
You must be signed in to change notification settings - Fork 0
Timer Library
Person8880 edited this page Jul 8, 2013
·
3 revisions
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( 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()
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()
Shared.Message( tostring( Time ) )
Time = Time - 1
end )
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.