LogicMachine Forum
Get variable change time - Printable Version

+- LogicMachine 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: Get variable change time (/showthread.php?tid=2293)



Get variable change time - MantasJ - 20.10.2019

Hello,

I want to do such scenario: whenever my boolean variable changes state to "false", I would like to know how much time it needed to become "false" from "true". How can I effectively achieve this?

Thank You!


RE: Get variable change time - Erwin van der Zwart - 20.10.2019

Hi,

Try this:
Code:
value = event.getvalue() if value == true then   storage.set(_SCRIPTNAME, os.time()) else   lastupdatetime = storage.get(_SCRIPTNAME)   if lastupdatetime then     difference = os.time() - lastupdatetime     log(difference)   end end
BR,

Erwin


RE: Get variable change time - MantasJ - 22.10.2019

Thank You! I have thought of something like this myself but thought that maybe there is a seperate function for this Smile