VE Lua Documentation

Press F to search!

toggleIgnitionLevelOnUp

Definition


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

local function toggleIgnitionLevelOnUp()
  if ignitionWasStartingEngine and M.values.ignitionLevel < 3 then
    --this case happens when the vehicle controller already switched to level 2 by itself after the engine fired up
    --make sure to pretend that we are still in level 3 so that the following logic works. Not nice, but couldn't find a better solution that actually works
    --this logic is also needed so that we can set level 3 from external (eg GE) and have the engine start autoamtically and go back to level 2 after doing so
    --(vehicle controller switches to level 2 after engine fired up)
    setIgnitionLevel(3)
  end
  local currentIgnitionLevel = M.values.ignitionLevel
  updateIgnitionStarterHandler = nop
  ignitionHoldingStarterTimer = 0
  ignitionWasStartingEngine = false

  if currentIgnitionLevel == 0 then
    setIgnitionLevel(1)
  elseif currentIgnitionLevel == 1 then
    if previousIgnitionLevel < currentIgnitionLevel then
      setIgnitionLevel(2)
    else
      setIgnitionLevel(0)
    end
  elseif currentIgnitionLevel == 2 then
    setIgnitionLevel(1)
  elseif currentIgnitionLevel == 3 then
    setIgnitionLevel(2)
  end
end

Callers

@/ui/modules/apps/SimplePowertrainControl/app.js
            svgIgnition[1].on('mouseup', function () {
              bngApi.activeObjectLua('electrics.toggleIgnitionLevelOnUp()')
            })
@/lua/vehicle/electrics.lua
              M.toggleIgnitionLevelOnDown()
              M.toggleIgnitionLevelOnUp()
            end
@/lua/ge/extensions/gameplay/discover/newPlayerExperience.lua
    label = 'ui.common.ignition',
    onClick = "getPlayerVehicle(0):queueLuaCommand('electrics.toggleIgnitionLevelOnDown() electrics.toggleIgnitionLevelOnUp()')",
  },
@/ui/ui-vue/mockdata/inputBindings.js
                "title": "ui.inputActions.vehicle.toggleIgnitonLevel.title",
                "onUp": "electrics.toggleIgnitionLevelOnUp()",
                "onDown": "electrics.toggleIgnitionLevelOnDown()",