GE Lua Documentation

Press F to search!

onVehicleSelected

Definition


-- @/lua/ge/extensions/scenario/scenarios.lua:1864

local function onVehicleSelected(vehicleData)
  if not scenario then return end
  -- log('I', logTag, 'onVehicleSelected called: '..dumps(vehicleData))
  if vehicleData.model and vehicleData.config then
    scenario.userSpawningData = createPlayerSpawningData(vehicleData.model, vehicleData.config, vehicleData.color, vehicleData.licenseText)
    local playerVehicle = getPlayerVehicle(0)
    if playerVehicle then
      core_vehicles.replaceVehicle(scenario.userSpawningData.model, scenario.userSpawningData.options)
      scenetree.ScenarioObjectsGroup:addObject(playerVehicle)
    else
      --Add set to correct Loading spot. if not the new car spawns at 0,0,0 (more likely at a random place)
      core_vehicles.spawnNewVehicle(scenario.userSpawningData.model, scenario.userSpawningData.options)
    end
    freezeAll(1)
  end
end

Callers

@/lua/ge/extensions/flowgraph/nodes/ui/vehicleSelector.lua

function C:onVehicleSelected(vehData, fullData)
  self._selectedVehData = vehData