NETIO Lua Tips & Philosophy

From wiki.netio-products.com
Revision as of 17:48, 11 July 2019 by Bbakala (talk | contribs) (Created page with "== Script starting == LUA Scripts in NETIO are event driven. That means if some event is triggered the script run exactly once. One of "triggers" is f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Script starting

LUA Scripts in NETIO are event driven. That means if some event is triggered the script run exactly once. One of "triggers" is for example System started up. You can find list of all events called "triggers" in NETIO Lua Reference.

Periodical scipts

In NETIO there is no way for triggering scripts periodically (e.g. every 10 seconds) usng standard triggers. For such scripts the trigger System started up and the function delay() must be used. This function calls itself and allows to run some procedures periodically.

  • Example switching output 1 every 10 seconds:
DoPeriod = 10 -- repeat period in seconds
-------------------------------------------------
function doPeriodically()
     -- your periodical code
     -- your periodical code
     -- your periodical code
     -- your periodical code
     -- your periodical code
     -- your periodical code
  delay(DoPeriod,function() doPeriodically() end)
end

doPeriodically()
  • This script can be launch using e.g. System started up trigger.
  • Only way how to disable these scripts is restart of NETIO, or usage of global variables.

Debugging

To debug your code, use log() and logf() functions. See the output in system events log.