Timers

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Timers

Post 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 207 times
Last edited by Kaze on Sun Mar 15, 2009 9:25 pm, edited 2 times in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Simple timers

Post 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)
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: Simple timers

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Simple timers

Post by bartbes »

Isn't that hard, is it?
Talking about usage I think it makes things easier.
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: Timers

Post by Kaze »

Updated.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Timers

Post by bartbes »

Great! (Just like user support)
User avatar
S-Rave
Prole
Posts: 39
Joined: Wed Feb 25, 2009 4:41 pm

Re: Timers

Post by S-Rave »

Woohoo! Awesome!
srejv
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: Timers

Post by Kuromeku »

I already made this as part of the short-lived kudoLib, sigh, but good job anyway.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests