GE Lua Documentation

Press F to search!

setVehicleCameraByIndexOffset

Definition


-- @/lua/ge/extensions/core/camera.lua:957

local function setVehicleCameraByIndexOffset(player, offset)
  -- if we're in a global camera, just switch back regular game camera, whichever that was
  if activeGlobalCameraName then
    setGlobalCameraByName(nil)
    displayCameraNameUI(player)
    return
  end

  local vdata = getVdata(player)
  if not vdata then return end

  -- this loop is supposed to skip over hidden/disabled cameras
  local focusedCamId = getCamIdFromName(vdata.focusedCamName)
  for i = 1, #configuration do
    focusedCamId = focusedCamId + offset
    if focusedCamId > #configuration then focusedCamId = 1 end
    if focusedCamId < 1 then focusedCamId = #configuration end
    local m = configuration[focusedCamId]
    local enabled = m.enabled
    local visible = vdata.cameras[m.name] and not vdata.cameras[m.name].hidden
    if visible and enabled then break end
  end

  _setVehicleCameraByIndex(vdata, focusedCamId)
  displayCameraNameUI(player)
  getGlobalCameras().transition:start()
end

Callers

@/ui/ui-vue/mockdata/inputBindings.js
                "title": "ui.inputActions.camera.switch_camera_next.title",
                "onDown": "if core_camera then core_camera.setVehicleCameraByIndexOffset(PLAYER, 1) extensions.hook('trackCamMode') end",
                "order": 1,
                "title": "ui.inputActions.camera.switch_camera_prev.title",
                "onDown": "if core_camera then core_camera.setVehicleCameraByIndexOffset(PLAYER, -1) extensions.hook('trackCamMode') end",
                "order": 1,
@/lua/ge/extensions/career/modules/playerDriving.lua
    initData.finishedPath = function(this)
      core_camera.setVehicleCameraByIndexOffset(0, 1)
    end