VE Lua Documentation

Press F to search!

smartParkingBrake

Definition


-- @/lua/vehicle/controller/vehicleController/vehicleController.lua:404

-- will smartly decide whether the user is actually parking the car (toggle), or just drifting around (temporary brake)
local function smartParkingBrake(ivalue, filter, isAxisOverride)
  filter = filter or FILTER_DIRECT
  local speed = electrics.values.wheelspeed
  if not speed then -- not a typical car, so just set the pbrake as instructed
    input.event("parkingbrake", ivalue, filter)
  end

  -- are we sliding or rolling?
  local isAxis = filter == FILTER_DIRECT or filter == FILTER_PAD
  --this used in certain cases where we need to interact with the smart parking brake externally (for example the airbrakes)
  if isAxisOverride ~= nil then
    isAxis = isAxisOverride
  end
  local rolling = abs(speed) > 2.8 -- ~10km/h
  local skidding = handBrakeHandling.smartParkingBrakeSlip > 10000

  -- decide what to do, based on context
  if rolling or skidding or isAxis then
    input.event("parkingbrake", ivalue, filter) -- transparent use / temporary pbrake
  elseif ivalue > 0.5 then -- car is parked, use onDown to toggle pbrake
    input.toggleEvent("parkingbrake")
  elseif input.state.parkingbrake.val > 0.5 then
    handBrakeHandling.smartParkingBrakeActive = true
  end
end

Callers

@/lua/vehicle/controller/braking/hydraulicPumpBrake.lua
    if controller.mainController.smartParkingBrake then
      controller.mainController.smartParkingBrake(1, FILTER_DIRECT, true)
    else
    if controller.mainController.smartParkingBrake then
      controller.mainController.smartParkingBrake(0, FILTER_DIRECT, false)
    end
@/lua/vehicle/controller/vehicleController/vehicleController.lua
  if gearboxHandling.behavior == "arcade" and electrics.values.ignitionLevel < 2 and vehicleSpeed < 1 then
    smartParkingBrake(1)
    handBrakeHandling.smartParkingBrakeActive = true
  if handBrakeHandling.smartParkingBrakeActive and electrics.values.parkingbrake > 0 and M.throttle > 0 and electrics.values.ignitionLevel == 2 then
    smartParkingBrake(0)
    handBrakeHandling.smartParkingBrakeActive = false
  if handBrakeHandling.smartParkingBrakeActiveUponSpawn then
    smartParkingBrake(1)
    --only make it the smart version if we are in arcade mode
@/ui/ui-vue/mockdata/inputBindings.js
                "cat": "vehicle",
                "onChange": "if controller.mainController.smartParkingBrake then controller.mainController.smartParkingBrake(VALUE, FILTERTYPE) else input.event('parkingbrake', VALUE, FILTERTYPE) end",
                "title": "ui.inputActions.vehicle.parkingbrake.title",
@/lua/vehicle/controller/pneumatics/airbrakes.lua
    if controller.mainController.smartParkingBrake then
      controller.mainController.smartParkingBrake(1, FILTER_DIRECT, true)
    else
      --"disable" parking brake, it stays on until you try to accelerate now
      controller.mainController.smartParkingBrake(0, FILTER_DIRECT, false)
    end