This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Execution of a resident script
#9
I couldn't do something. Can you give a concrete example of how to put this sample code into a library, running as a resident script with 0 sleep time?
Code:
if not pirs then
  pirs = {
    { input = '1/1/1', output = '2/1/1' },
    { input = '1/1/2', output = '2/1/2' },
  }
end

now = os.time()
for _, pir in ipairs(pirs) do
  key = 'pir_timer_' .. pir.input
  delta = now - storage.get(key, 0)

  -- set output to 0% after 1 hour
  if delta > 60 * 60 then
    grp.checkwrite(pir.output, 0)
  -- set output to 20% after 30 minutes
  elseif delta > 30 * 60 then
    grp.checkwrite(pir.output, 20)
  end
Reply


Messages In This Thread
Execution of a resident script - by a455115 - 04.05.2023, 11:19
RE: Execution of a resident script - by admin - 04.05.2023, 11:45
RE: Execution of a resident script - by admin - 04.05.2023, 13:13
RE: Execution of a resident script - by admin - 04.05.2023, 14:06
RE: Execution of a resident script - by admin - 04.05.2023, 14:18
RE: Execution of a resident script - by a455115 - 18.05.2023, 07:31

Forum Jump: