25.04.2018, 06:21
Code:
mintimer = 1 -- minimum timer value in minutes
maxtimer = 30 -- maximum timer value in minutes
objects = {
{
output = '1/1/1',
timer = '2/1/1',
enable = '3/1/1',
},
{
output = '1/1/2',
timer = '2/1/2',
enable = '3/1/3',
},
{
output = '1/1/3',
timer = '2/1/3',
enable = '3/1/3',
}
}
function dosleep(obj)
local timer = grp.getvalue(obj)
timer = tonumber(timer)
if timer then
if timer < mintimer then
timer = mintimer
elseif timer > maxtimer then
timer = maxtimer
end
sleep(timer * 60) -- minutes -> seconds
end
end
for _, item in ipairs(objects) do
if grp.getvalue(item.enable) then
grp.write(item.output, true)
dosleep(item.timer)
grp.write(item.output, false)
end
end