cron
A set of functions for executing actions at a certain time interval by Enrique García Cota aka kikito.
local cron = require 'cron' local function printMessage() print('Hello') end -- the following calls are equivalent: local c1 = cron.after(5, printMessage) local c2 = cron.after(5, print, 'Hello') c1:update(2) -- will print nothing, the action is not done yet c1:update(5) -- will print 'Hello' once c1:reset() -- reset the counter to 0 -- prints 'hey' 5 times and then prints 'hello' while not c1:update(1) do print('hey') end -- Create a periodical clock: local c3 = cron.every(10, printMessage) c3:update(5) -- nothing (total time: 5) c3:update(4) -- nothing (total time: 9) c3:update(12) -- prints 'Hello' twice (total time is now 21)
Links
Category: