-- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
-- If a copy of the bCDDL was not distributed with this
-- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt

local M = {}

local function onInit()
  electrics.values.lift = 0
end

local function onReset()
	onInit()
end

local liftDir = 0
local function startLift(dir)
  liftDir = dir
end

local function endLift()
  liftDir = 0
end

local function updateGFX(dt)
  if liftDir == 0 then return end
  
  electrics.values.lift = electrics.values.lift + (liftDir * dt)
  if electrics.values.lift > 1  then electrics.values.lift = 1 end
  if electrics.values.lift < -1 then electrics.values.lift = -1 end
end

-- public interface
M.onInit      = onInit
M.onReset     = onReset
M.updateGFX = updateGFX

M.startLift = startLift
M.stopLift = endLift

return M