Page 1 of 1

Timers

Posted: Sun Mar 15, 2009 4:21 pm
by Kaze
Usage:
Include timer.lua

Code: Select all

timer.new( delay, extra repitions(-1 will never stop), callback, ... arguments )
This returns a timer object, of which these functions are applicable:

Code: Select all

timer:update( dt )
timer:setCallback( callback, ... arguments )
timer:stop( )
timer:start( )
timer:reset( boolShouldResetReps )
timer:setDelay( delay, reps )
Simple timers
Add this to update:

Code: Select all

timer.update( dt )
timer.newSimple:

Code: Select all

timer.newSimple( delay, callback, ... arguments )
Public domain.
Timers.love
Press any key, a "Hello world" will display 5 seconds after.
(1003 Bytes) Downloaded 208 times

Re: Simple timers

Posted: Sun Mar 15, 2009 4:27 pm
by bartbes
I just looked at it, but it would be even nicer if you could just update individual timers. (or at least have the possibility to do so) Example:

Code: Select all

mytimer = timer.new(5, print, "5 seconds passed")
mytimer:update(dt)
--or double speed
mytimer:update(dt*2)

Re: Simple timers

Posted: Sun Mar 15, 2009 6:40 pm
by Kaze
bartbes wrote:I just looked at it, but it would be even nicer if you could just update individual timers. (or at least have the possibility to do so) Example:

Code: Select all

mytimer = timer.new(5, print, "5 seconds passed")
mytimer:update(dt)
--or double speed
mytimer:update(dt*2)
The thread is titled "Simple timers" for a reason.
Might do an advanced version later.

Re: Simple timers

Posted: Sun Mar 15, 2009 6:50 pm
by bartbes
Isn't that hard, is it?
Talking about usage I think it makes things easier.

Re: Timers

Posted: Sun Mar 15, 2009 9:24 pm
by Kaze
Updated.

Re: Timers

Posted: Mon Mar 16, 2009 6:42 am
by bartbes
Great! (Just like user support)

Re: Timers

Posted: Mon Mar 16, 2009 11:19 pm
by S-Rave
Woohoo! Awesome!

Re: Timers

Posted: Tue Mar 17, 2009 10:38 am
by Kuromeku
I already made this as part of the short-lived kudoLib, sigh, but good job anyway.