mirror of
https://github.com/kikito/cron.lua.git
synced 2024-12-19 18:34:20 +00:00
update README
This commit is contained in:
parent
2fc72cf66d
commit
f93cbfb6d8
@ -10,6 +10,31 @@ h1. Examples of use
|
|||||||
* @cron.reset()@ removes all timed and periodic actions, and resets the time passed back to 0.
|
* @cron.reset()@ removes all timed and periodic actions, and resets the time passed back to 0.
|
||||||
* @cron.update(dt)@ is needed to be executed on the main program loop. @dt@ is the amount of time that has passed since the last iteration. When @cron.update@ is executed, cron will check the list of pending actions and execute them if needed.
|
* @cron.update(dt)@ is needed to be executed on the main program loop. @dt@ is the amount of time that has passed since the last iteration. When @cron.update@ is executed, cron will check the list of pending actions and execute them if needed.
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
local cron = require 'cron'
|
||||||
|
|
||||||
|
local function printMessage()
|
||||||
|
print('Hello')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- the following calls are equivalent:
|
||||||
|
cron.after(5, printMessage)
|
||||||
|
cron.after(5, print, 'Hello')
|
||||||
|
|
||||||
|
cron.update(5) -- will print 'Hello' twice
|
||||||
|
|
||||||
|
-- this will print the message periodically:
|
||||||
|
local id = cron.every(10, printMessage)
|
||||||
|
|
||||||
|
cron.update(5) -- nothing
|
||||||
|
cron.update(4) -- nothing
|
||||||
|
cron.update(12) -- prints 'Hello' twice
|
||||||
|
|
||||||
|
cron.cancel(id) -- stops the execution the element defined by id. Works with periodical or one-time actions.
|
||||||
|
|
||||||
|
cron.reset() -- stops all the current actions, both timed ones and periodical ones.
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
h1. Gotchas / Warnings
|
h1. Gotchas / Warnings
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user