toggleDeviceMode
Definition
-- @/lua/vehicle/powertrain.lua:848
local function toggleDeviceMode(name)
local device = powertrainDevices[name]
if not device then
return
end
local found = false
local newMode = device.mode
for _, v in pairs(device.availableModes) do
if found then
newMode = v
found = false
break
elseif device.mode == v then
found = true
end
end
if found then
newMode = device.availableModes[next(device.availableModes)]
end
setDeviceMode(name, newMode)
return newMode
end
Callers
@/lua/vehicle/powertrain/rangeBox.lua
}
extensions.ui_simplePowertrainControl.setButton("powertrain_device_mode_shortcut_" .. device.name, device.uiName, modeIconLookup[device.mode], nil, nil, string.format("powertrain.toggleDeviceMode(%q)", device.name))
end
@/lua/ge/extensions/gameplay/discover/newPlayerExperience.lua
setupVehs[v:getID()] = [[
for _, v in ipairs(powertrain.getDevicesByType("differential")) do powertrain.toggleDeviceMode(v.name) end
controller.getControllerSafe("frontLockControl").setDriveMode('locked')
@/lua/vehicle/controller/4wd.lua
if rangeBox then
powertrain.toggleDeviceMode(rangeBox.name)
end
if shaft and not shaft.isPhysicallyDisconnected then
powertrain.toggleDeviceMode(shaft.name)
end
@/lua/vehicle/powertrain/shaft.lua
end
extensions.ui_simplePowertrainControl.setButton("powertrain_device_mode_shortcut_" .. device.name, device.uiName, modeIconLookup[device.mode], nil, nil, string.format("powertrain.toggleDeviceMode(%q)", device.name))
end
@/lua/ge/extensions/gameplay/missions/missionManager.lua
veh:queueLuaCommand([[
for _, v in ipairs(powertrain.getDevicesByType("differential")) do powertrain.toggleDeviceMode(v.name) end
]])
@/ui/modules/apps/SimplePowertrainControl/app.js
el.on('mousedown', function () {
bngApi.activeObjectLua('powertrain.toggleDeviceMode("' + components[i] + '")')
}).on('mouseover', function () {
@/lua/vehicle/powertrain/differential.lua
}
extensions.ui_simplePowertrainControl.setButton("powertrain_device_mode_shortcut_" .. device.name, device.uiName, modeIconLookup[device.mode], nil, nil, string.format("powertrain.toggleDeviceMode(%q)", device.name))
end
@/lua/vehicle/powertrain.lua
if v.type == "differential" and v.defaultToggle then
toggleDeviceMode(v.name)
end