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 whether you accept or reject these cookies being set.

Operating hours counter
Hey guys,

we want to create an operating hour counter for a Boolean address, does anyone have a finished script?

Thank you
Function from FB Editor
function fbe_operating_hours(input, reset, blockID)
  local inputValue = input.value and input.value ~= 0
  if reset and reset ~= 0 then
    if inputValue then
      storage.set(blockID .. "_start", os.time())
    return inputValue and 0 or nil
  elseif inputValue then
    local start = storage.get(blockID .. "_start")
    if start == nil then
      start = input.updatetime
      storage.set(blockID .. "_start", start)
    return (os.time() - start) / 3600
    storage.delete(blockID .. "_start")
    return nil

Forum Jump: