Difference between revisions of "cron"

m (Adding keyword.)
m (Added: Other Languages)
 
Line 1: Line 1:
{{#set:Name=cron}}
 
{{#set:LOVE Version=Any}}
 
{{#set:Description=A set of functions for executing actions at a certain time interval.}}
 
{{#set:Keyword=Timer}}
 
 
A set of functions for executing actions at a certain time interval by Enrique García Cota aka [https://github.com/kikito kikito].
 
A set of functions for executing actions at a certain time interval by Enrique García Cota aka [https://github.com/kikito kikito].
  
Line 36: Line 32:
 
</source>
 
</source>
  
 
+
== Links ==
'''Links'''
 
 
* [https://github.com/kikito/cron.lua Github]
 
* [https://github.com/kikito/cron.lua Github]
 
* [https://github.com/kikito/cron.lua/blob/master/README.md Readme]
 
* [https://github.com/kikito/cron.lua/blob/master/README.md Readme]
 
* [https://github.com/kikito/cron.lua/blob/master/cron.lua cron.lua]
 
* [https://github.com/kikito/cron.lua/blob/master/cron.lua cron.lua]
  
 +
{{#set:Name=cron}}
 +
{{#set:LOVE Version=Any}}
 +
{{#set:Description=A set of functions for executing actions at a certain time interval.}}
 +
{{#set:Keyword=Timer}}
 +
[[Category:Libraries]]
  
[[Category:Libraries]]
+
== Other Languages ==
 +
{{i18n|cron}}

Latest revision as of 15:17, 15 December 2019

A set of functions for executing actions at a certain time interval by Enrique García Cota aka kikito.

Download

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

Other Languages