VE Lua Documentation

Press F to search!

horn

Definition


-- @/lua/vehicle/electrics.lua:1000

local function horn(state)
  hornState = state
  if hornState then
    hornSound1 = hornSound1 or sounds.createSoundscapeSound("horn")
    if not hornSound1 then
      return
    end
    if hornSound2 then
      obj:setVolume(hornSound2, 0)
    end
    obj:setVolume(hornSound1, 1)
    obj:playSFX(hornSound1)
  else
    if hornSound1 then
      obj:stopSFX(hornSound1)
    end
    hornSound1, hornSound2 = hornSound2, hornSound1
  end
end

Callers

@/ui/ui-vue/mockdata/inputBindings.js
                "title": "ui.inputActions.vehicle.horn.title",
                "onUp": "electrics.horn(false)",
                "onDown": "electrics.horn(true)",
                "onUp": "electrics.horn(false)",
                "onDown": "electrics.horn(true)",
                "order": 29,
@/lua/vehicle/ai.lua

  if electrics.values.horn == 1 then electrics.horn(false) end
  if electrics.values.signal_left_input or electrics.values.signal_right_input then electrics.set_warn_signal(false) end
  if parameters.enableElectrics and trafficStates.action.hornTimer == 0 then
    electrics.horn(true)
    trafficStates.action.hornTimerLimit = max(0.1, math.random())
  if trafficStates.action.hornTimer >= trafficStates.action.hornTimerLimit then
    electrics.horn(false)
    trafficStates.action.hornTimer = -1
@/lua/ge/extensions/gameplay/traffic/vehicle.lua
  obj:queueLuaCommand('electrics.set_warn_signal(0)')
  obj:queueLuaCommand('electrics.horn(false)')
end
function C:honkHorn(duration) -- set horn with duration
  getObjectByID(self.id):queueLuaCommand('electrics.horn(true)')
  self.queuedFuncs.horn = {timer = duration or 1, vLua = 'electrics.horn(false)'}
  getObjectByID(self.id):queueLuaCommand('electrics.horn(true)')
  self.queuedFuncs.horn = {timer = duration or 1, vLua = 'electrics.horn(false)'}
end