Logic Machine Forum
Time to switch from "false" to "true"! - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Time to switch from "false" to "true"! (/showthread.php?tid=2334)



Time to switch from "false" to "true"! - phongvucba - 11.11.2019

Hi everybody ! I have a little trouble? Hope everybody help please:

-My address changes from "false" to "true", it needs to be 1.254s. I see it in the "Update at" section. How do I know that time? I want to do something with this "1,254s".

Thank so much everybody !


RE: Time to switch from "false" to "true"! - admin - 11.11.2019

delta variable will have the time between FALSE and TRUE values in seconds.
Code:
value = event.getvalue()

if value then
  prevtime = storage.get('prevtime')
  
  if prevtime then
    storage.delete('prevtime')
    delta = os.udifftime(unpack(prevtime))
    log(delta)
  end
else
  storage.set('prevtime', { os.microtime() })
end