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.

Timer - How to improve
#1
Hi everyone,

I'm using a script found on this forum, by Daniel, I believe, which I've modified a little to suit my needs. The only problem I'm having is that every time a READ passes on the bus, the updatetime value is updated, so my timer doesn't work as expected. Do you have any ideas? Thanks in advance

Code:
timers = {   {     name = 'TEST',     input = '0/6/100',     inputValueForTrigger = false,     output = '14/0/202',     outputValue = true,     outputTimeMinutes = 6,     writeInverseValue = true   }, } for _, timer in ipairs(timers) do        -- find required object   obj = grp.find(timer.input)   -- object exists and current state is "on"   if obj and obj.data == timer.inputValueForTrigger then     -- delta is in seconds        delta = os.time() - obj.updatetime         -- switch when timer expires     if delta >= timer.outputTimeMinutes * 60 then            grp.checkwrite(timer.output, timer.outputValue)     end       else         if obj then       if timer.writeInverseValue then         grp.checkwrite(timer.output, not timer.outputValue)       end     end       end   end
Reply


Messages In This Thread
Timer - How to improve - by Fcs - 10.12.2024, 19:32
RE: Timer - How to improve - by admin - 11.12.2024, 08:12
RE: Timer - How to improve - by Fcs - 12.12.2024, 09:46
RE: Timer - How to improve - by admin - 13.12.2024, 11:52
RE: Timer - How to improve - by Fcs - 19.12.2024, 13:52

Forum Jump: