setMode
Definition
-- @/lua/vehicle/ai.lua:6566
local function setMode(mode)
if tableSizeC(wheels.wheels) == 0 then return end
if mode ~= nil then
if M.mode ~= mode then -- new AI mode is not the same as the old one
obj:queueGameEngineLua('onAiModeChange('..objectId..', "'..mode..'")')
end
M.mode = mode
end
if M.extAvoidCars == 'off' or M.extAvoidCars == 'on' then
opt.avoidCars = M.extAvoidCars
else
opt.avoidCars = (M.mode == 'manual' and 'off' or 'on')
end
if M.mode ~= 'script' then
if M.mode ~= 'disabled' and M.mode ~= 'stop' then
resetMapAndRoute()
mapmgr.requestMap()
M.updateGFX = updateGFX
targetSpeedDifSmoother:set(0)
targetSpeedSmoother:set(ego.speed)
if controller.mainController then
if electrics.values.gearboxMode == 'realistic' then
restoreGearboxMode = true
end
controller.mainController.setGearboxMode('arcade')
end
ego.wheelBase = calculateWheelBase()
if M.mode == 'flee' or M.mode == 'chase' or M.mode == 'follow' then
setAggressionMode('rubberBand')
end
if M.mode == 'traffic' then
setSpeedMode('legal')
driveInLane('on')
setTractionModel(1)
setParameters({minStTargetDist = 2})
setSpeedProfileMode('Back')
obj:setSelfCollisionMode(2)
obj:setAerodynamicsMode(2)
else
obj:setSelfCollisionMode(1)
obj:setAerodynamicsMode(1)
end
end
if M.mode == 'disabled' then
driveCar(0, 0, 0, 0)
M.updateGFX = nop
currentRoute = nil
if controller.mainController and restoreGearboxMode then
controller.mainController.setGearboxMode('realistic')
end
end
stateChanged()
sounds.updateObjType()
end
visDebug.trajecRec = {last = 0}
visDebug.routeRec = {last = 0}
end
Callers
@/lua/ge/extensions/editor/trafficManager.lua
if sessionData.aiType == "basic" then
veh:queueLuaCommand('ai.setMode("'..sessionData.aiMode..'")')
elseif sessionData.aiType == "target" then
elseif sessionData.aiType == "target" then
veh:queueLuaCommand('ai.setMode("manual")')
elseif sessionData.aiType == "script" then
veh:queueLuaCommand('ai.setMode("stop")')
gameplay_traffic.removeTraffic(sessionData.id)
@/lua/vehicle/extensions/gameplayInterfaceModules/interactAI.lua
local mode = params[1]
ai.setMode(mode)
end
if mode == "stop" then
BeamEngine:queueAllObjectLua('ai.setMode("stop")')
obj:queueGameEngineLua("extensions.gameplay_traffic.deactivate()")
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/follow.lua
local targetId = self.pinIn.targetId.value or be:getPlayerVehicleID(0)
veh:queueLuaCommand('ai.setMode("follow")')
veh:queueLuaCommand('ai.setTargetObjectID('..targetId..')')
@/lua/ge/extensions/scenario/raceMarkers/sideHologramMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/inspector/External/three.js/three.js
function setMode( value ) {
function setMode( value ) {
state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
renderer.setMode( _gl.LINES );
case TrianglesDrawMode:
renderer.setMode( _gl.TRIANGLES );
break;
case TriangleStripDrawMode:
renderer.setMode( _gl.TRIANGLE_STRIP );
break;
case TriangleFanDrawMode:
renderer.setMode( _gl.TRIANGLE_FAN );
break;
renderer.setMode( _gl.LINES );
renderer.setMode( _gl.LINE_LOOP );
renderer.setMode( _gl.LINE_STRIP );
renderer.setMode( _gl.POINTS );
@/lua/ge/extensions/gameplay/drift/stuntZones/nearPole.lua
self.marker:setToCheckpoint({pos = vehPos + markerOffset, radius = 5, fadeNear = 1000, fadeFar = 0})
self.marker:setMode('default')
end
@/lua/vehicle/powertrain/differential.lua
local function setMode(device, mode)
local isValidMode = false
@/lua/ge/extensions/editor/aiTests.lua
for k, v in pairs(vehicles) do
getObjectByID(k):queueLuaCommand("ai.setMode('stop')")
end
@/lua/ge/extensions/scenario/raceMarkers/cylinderMarker.lua
function C:setMode(mode)
--dump(self.id .. " -> " .. mode)
@/lua/ge/extensions/flowgraph/modules/timerModule.lua
-- sets the desired mode of the timer
function C:setMode(id, mode)
self.variables:set(id.."mode", mode)
@/lua/vehicle/powertrain/torqueConverter.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/scenario/raceMarkers/crawlMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/vehicle/controller/vehicleController/shiftLogic/dctGearbox.lua
if automaticHandling.mode == "P" then
gearbox:setMode("park")
elseif automaticHandling.mode == "N" then
elseif automaticHandling.mode == "N" then
gearbox:setMode("neutral")
else
else
gearbox:setMode("drive")
local gearIndex = gearbox[dct.primaryAccess.gearIndexName]
@/lua/ge/extensions/core/chat.lua
connected = true
s:setMode({add = 'x'})
s:join(startChannel)
@/lua/vehicle/bdebugImpl.lua
local function setMode(modeVar, modesVar, mode)
if M.state.vehicle[modeVar] and M.state.vehicle[modesVar] then
local function nodetextModeChange(change)
setMode("nodeTextMode", "nodeTextModes", M.state.vehicle.nodeTextMode + change)
local function nodevisModeChange(change)
setMode("nodeVisMode", "nodeVisModes", M.state.vehicle.nodeVisMode + change)
local function nodedebugtextModeChange(change)
setMode("nodeDebugTextMode", "nodeDebugTextModes", M.state.vehicle.nodeDebugTextMode + change)
local function skeletonModeChange(change)
setMode("beamVisMode", "beamVisModes", M.state.vehicle.beamVisMode + change)
local function colTrisModeChange(change)
setMode("collisionTriangleVisMode", "collisionTriangleVisModes", M.state.vehicle.collisionTriangleVisMode + change)
local function cogChange(change)
setMode("cogMode", "cogModes", M.state.vehicle.cogMode + change)
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/traffic.lua
veh:queueLuaCommand('ai.setMode("traffic")')
end
@/lua/ge/extensions/gameplay/race/segment.lua
else
self:setMode('waypoint')
end
function C:setMode(mode)
self.mode = mode
end
self:setMode(data.mode)
for _, c in ipairs(data.capsules or {}) do
@/lua/vehicle/ai.lua
if M.mode == "traffic" then
setMode("disabled")
setRecoverOnCrash(false)
else
setMode("traffic")
setRecoverOnCrash(true)
driveCar(0, 0, 0, 0)
setMode() -- some scenarios don't work if this is changed to setMode('disabled')
end
driveCar(0, 0, 0, 0)
setMode() -- some scenarios don't work if this is changed to setMode('disabled')
end
if not (mode == 'disabled' and M.mode == 'disabled') then
setMode()
end
@/lua/common/libs/LuaIRC/asyncoperations.lua
function meta:setMode(t)
local target = t.target or self.nick
@/lua/vehicle/powertrain.lua
for k, v in pairs(previousDeviceModes) do
powertrainDevices[k]:setMode(v)
end
previousDeviceModes[name] = mode
device:setMode(mode)
guihooks.message(device.uiName .. " Mode: " .. mode, 5, "vehicle.powertrain.diffmode." .. device.name)
@/lua/vehicle/extensions/tech/techCore.lua
M.handleSetAiMode = function(request)
ai.setMode(request['mode'])
ai.stateChanged()
else
ai.setMode('disabled')
end
@/lua/vehicle/powertrain/splitShaft.lua
local function setMode(device, mode)
device.mode = mode
@/lua/vehicle/powertrain/electricServo.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/scenario/race_marker.lua
for name, marker in pairs(markers[markerListName] or {}) do
marker:setMode(wpModes[name] or 'hidden')
end
@/lua/ge/extensions/core/hotlapping.lua
if veh.isHotlapping then
veh:queueLuaCommand('ai.setMode("stop")')
@/ui/modules/lightrunner/lightrunner.js
if ($stateParams.mode) {
LightRunnerService.setMode($stateParams.mode)
}
@/lua/ge/extensions/scenario/raceMarkers/noneMarker.lua
function C:setMode(mode)
end
@/lua/vehicle/controller/axleLift.lua
local function setMode(mode)
currentMode = mode
local function toggleMode()
setMode(getNextMode())
end
velocitySmoother:reset()
setMode(modes.auto)
if parameters.mode ~= nil then
setMode(parameters.mode)
end
@/lua/ge/extensions/gameplay/race/race.lua
getObjectByID(id):queueLuaCommand('ai.setMode("stop")')
end
@/gameplay/missionTypes/chase/customNodes/suspectAiNode.lua
else -- just uses flee mode as default
veh:queueLuaCommand('ai.setMode("flee")')
self.aiMode = 'flee'
if self.aiMode ~= 'flee' and self.pinIn.setFlee.value then
veh:queueLuaCommand('ai.setMode("flee")')
self.aiMode = 'flee'
if self.aiMode ~= 'stop' and self.pinIn.setStop.value then
veh:queueLuaCommand('ai.setMode("stop")')
self.aiMode = 'stop'
@/lua/vehicle/powertrain/shaft.lua
local function setMode(device, mode)
local isValidMode = false
@/lua/ge/extensions/gameplay/traffic.lua
if stopAi and traffic[id].isAi then
obj:queueLuaCommand('ai.setMode("stop")')
end
@/lua/ge/extensions/scenario/raceMarkers/sideColumnMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/ge/extensions/scenario/raceMarkers/overhead.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/chase.lua
local targetId = self.pinIn.targetId.value or be:getPlayerVehicleID(0)
veh:queueLuaCommand('ai.setMode("chase")')
veh:queueLuaCommand('ai.setTargetObjectID('..targetId..')')
@/lua/vehicle/powertrain/automaticGearbox.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/editor/raceEditor/pathnodes.lua
if seg:getFrom().mode == 'navgraph' and seg:getTo().mode == 'navgraph' then
seg:setMode('navpath')
end
@/lua/vehicle/controller/vehicleController/shiftLogic/cvtGearbox.lua
if automaticHandling.mode == "P" then
gearbox:setMode("park")
elseif automaticHandling.mode == "N" then
elseif automaticHandling.mode == "N" then
gearbox:setMode("neutral")
elseif automaticHandling.mode == "R" then
elseif automaticHandling.mode == "R" then
gearbox:setMode("reverse")
else
else
gearbox:setMode("drive")
end
@/lua/vehicle/powertrain/dctGearbox.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/gameplay/traffic/vehicle.lua
local obj = getObjectByID(self.id)
obj:queueLuaCommand(string.format('ai.setMode("%s")', mode))
@/lua/ge/extensions/editor/raceEditor/segments.lua
local old = segment:onSerialize()
segment:setMode(newMode)
self:addHistory("Changed Mode of Segment", old)
@/lua/ge/extensions/gameplay/drift/stuntZones/hitPole.lua
self.marker:setToCheckpoint({pos = vehPos + markerOffset, radius = 5, fadeNear = 1000, fadeFar = 0})
self.marker:setMode('default')
end
@/lua/ge/extensions/flowgraph/nodes/scene/singleMarker.lua
self.marker:setToCheckpoint({pos = vec3(self.position), radius = self.radius, fadeNear = self.pinIn.fadeNearDist.value, fadeFar = self.pinIn.fadeFarDist.value})
self.marker:setMode('default')
end
@/lua/vehicle/controller/pneumatics/liftAxleControl.lua
local function setMode(mode)
currentMode = mode
if currentMode == modes.drop then
setMode(modes.lift)
else
else
setMode(modes.drop)
end
setMode(modes.lift)
end
@/lua/ge/extensions/scenario/raceMarkers/sideMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/vehicle/powertrain/viscousClutch.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/scenario/raceMarkers/attention.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/vehicle/extensions/tech/platooning.lua
obj:queueGameEngineLua(string.format("tech_platoonFunctions.removeVehicleFromPlatoon(%q)", lpack.encode(vehiclesData)))
ai.setMode('manual')
ai.setTargetObjectID(leaderID)
ai.setMode('follow')
ai.driveInLane('on')
ai.setTargetObjectID(leaderID)
ai.setMode('follow')
ai.driveInLane('on')
ai.setTargetObjectID(leaderID)
ai.setMode('follow')
ai.driveInLane('on')
ai.setSpeed(updatedSpeed)
ai.setMode(mode)
ai.driveInLane('on')
launched = false
ai.setMode('manual')
ui_message("Leader Exit Platoon", 5, "Tech", "forward")
ai.setSpeed(10)
ai.setMode('span')
ai.driveInLane('on')
ai.setSpeed(10)
ai.setMode('span')
ai.driveInLane('on')
ai.setSpeed(10)
ai.setMode('span')
ai.driveInLane('on')
electrics.values.brakeOverride = nil
ai.setMode('manual')
if debug then
@/lua/ge/extensions/scenario/raceMarkers/singleHologramMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/vehicle/powertrain/rangeBox.lua
local function setMode(device, mode)
device.mode = mode
@/lua/vehicle/controller/vehicleController/shiftLogic/automaticGearbox.lua
gearbox:setGearIndex(0)
gearbox:setMode("park")
elseif automaticHandling.mode == "N" then
gearbox:setGearIndex(0)
gearbox:setMode("neutral")
else
else
gearbox:setMode("drive")
if automaticHandling.mode == "R" and gearbox.gearIndex > -1 then
@/lua/ge/extensions/campaign/exploration.lua
destinationMarker:setToCheckpoint({pos = vec3(marker:getPosition()), radius = 5})
destinationMarker:setMode('default')
else
@/lua/ge/extensions/scenario/raceMarkers/ringMarker.lua
function C:setMode(mode)
if mode ~= 'hidden' then
@/lua/vehicle/controller/driveModes.lua
if device and device.setMode then
device:setMode(deviceMode)
end
@/lua/vehicle/powertrain/cvtGearbox.lua
local function setMode(device, mode)
device.mode = mode
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/flee.lua
local targetId = self.pinIn.targetId.value or be:getPlayerVehicleID(0)
veh:queueLuaCommand('ai.setMode("flee")')
veh:queueLuaCommand('ai.setTargetObjectID('..targetId..')')
@/lua/vehicle/controller/vehicleController/shiftLogic/cvtGearbox2.lua
if automaticHandling.mode == "P" then
gearbox:setMode("park")
elseif automaticHandling.mode == "N" then
elseif automaticHandling.mode == "N" then
gearbox:setMode("neutral")
elseif automaticHandling.mode == "R" then
elseif automaticHandling.mode == "R" then
gearbox:setMode("reverse")
else
else
gearbox:setMode("drive")
if automaticHandling.mode == "S" then
@/lua/vehicle/extensions/dynamicVehicleData.lua
print("Setting diff '" .. diff.name .. "' to locked")
diff:setMode("locked")
end
print("Setting shaft '" .. shaft.name .. "' to connected")
shaft:setMode("connected")
end
print("Setting rangebox '" .. rangebox.name .. "' to high")
rangebox:setMode("high")
end
print("Setting diff '" .. diff.name .. "' to locked")
diff:setMode("locked")
end
print("Setting shaft '" .. shaft.name .. "' to connected")
shaft:setMode("connected")
end
print("Setting rangebox '" .. rangebox.name .. "' to high")
rangebox:setMode("high")
end
print("Setting diff '" .. diff.name .. "' to locked")
diff:setMode("locked")
end
print("Setting shaft '" .. shaft.name .. "' to connected")
shaft:setMode("connected")
end
print("Setting rangebox '" .. rangebox.name .. "' to low")
rangebox:setMode("low")
end