function delay()

From wiki.netio-products.com
Revision as of 19:15, 18 April 2017 by Jturon (talk | contribs) (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…“)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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(number seconds, function callback)

Parameters

number seconds how much the callback will be delayed. function callback function 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

  • logf() to display formatted string