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.

Get variable change time
#1
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!
Reply
#2
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
Reply
#3
Thank You! I have thought of something like this myself but thought that maybe there is a seperate function for this Smile
Reply


Forum Jump: