25.01.2021, 09:08
This will send a string like 1d 4h 3m to 1/1/1:
Code:
delta = os.time() - obj.updatetime
timeout = ((RstDays) * 24 + (RstHours)) * 60 * 60
remaining = math.max(0, delta - timeout)
days = math.floor(remaining / 86400)
hours = math.floor((remaining % 86400) / 3600)
minutes = math.floor((remaining % 3600) / 60)
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm'
grp.update('1/1/1', txtremaining)
-- switch off when timer expires
if remaining == 0 then
grp.write(addr, false)
grp.write(Tc, grp.getvalue(TRef))
end