Difference between revisions of "Function delay()"
Jump to navigation
Jump to search
(Založena nová stránka s textem „{{DISPLAYTITLE:function delay()}} Run a function after specified number of seconds. delay() is non-blocking (following command in the script is executed im…“) |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
Run a function after specified number of seconds. delay() is non-blocking (following command in the script is executed immediately, before the callback function). | Run a function after specified number of seconds. delay() is non-blocking (following command in the script is executed immediately, before the callback function). | ||
| − | <i>nil</i> delay(number < | + | <i>nil</i> <b>delay</b>(<i>number</i> <code>seconds</code>, <i>function</i> <code>callback</code>) |
=== Parameters === | === Parameters === | ||
| − | <i>number</i> < | + | * <i>number</i> <code>seconds</code> how much the callback will be delayed. |
| − | <i>function</i> < | + | * <i>function</i> <code>callback</code> function to execute |
=== Return value === | === Return value === | ||
| Line 25: | Line 25: | ||
=== See also === | === See also === | ||
| − | * [[Function | + | * [[Function milliDelay()|milliDelay()]] to delay callback execution by milliseconds |
__NOTOC__ | __NOTOC__ | ||
Latest revision as of 19:54, 18 April 2017
Run a function after specified number of seconds. delay() is non-blocking (following command in the script is executed immediately, before the callback function).
nil delay(numberseconds, functioncallback)
Parameters
- number
secondshow much the callback will be delayed. - function
callbackfunction to execute
Return value
nil
Usage
-- logs counts down from 5 to 0
function countDown(from)
logf("%d", from)
if(from > 0) then
delay(1, function()
countDown(from-1)
end)
end
end
countDown(5)
See also
- milliDelay() to delay callback execution by milliseconds