First Vehicle Lua Mod

So, since we added a Lua modding/hooking API into our latest testing version, we enable the mod creators to extend the Lua functionality that we ship by default.

As example, we want to have speed-sensitive dynamic steering on certain hydros so that the steering of certain wheels will reduce the faster you get.

Let me walk you through how to get it working. (once we release the update to the public for sure)

1. Change your hydros so that they are not driven by the steering anymore: I.e. change

["x43l","x44l", {"factor": 0.20,"steeringWheelLock":700,"lockDegrees":35}],

to

["x43l","x44l", {"factor": 0.20,"steeringWheelLock":700,"lockDegrees":35, "inputSource":"steering_speeddependant"}],

2. add a new folder to your vehicle folder, called ’lua’. The game will load any .lua files in there.

3. write the lua extension (lua/rearSteering.lua):

-- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
-- If a copy of the bCDDL was not distributed with this
-- file, You can obtain one at http: https://beamng.com/bCDDL-1.1.txt
local M = {}
local maxSpeed = 10 -- in meters per second
local function init()
  if v.data.dynamicSteering.maxSpeed ~= nil and type(v.data.dynamicSteering.maxSpeed) == 'number' then
    maxSpeed = v.data.dynamicSteering.maxSpeed
  end
end

local function updateGFX(dt)
  electrics.values['steering_speeddependant'] = electrics.values['steering_input'] * math.max(0, (maxSpeed - math.abs(electrics.values['wheelspeed'])) / maxSpeed)
end

-- public interface
M.updateGFX = updateGFX
M.init      = init
return M

The updateGFX, init and reset functions are called automatically by the game. 🙂

To make it easier for the vehicle creator, one can add the gimmick to read out options by adding them to the .jbeam instead of hardcoding them into the lua. The above mod uses this new section in the jbeam file:

"dynamicSteering": { "maxSpeed": 10 }

BeamNG Major Updates

Sprouting Makeovers in BeamNG.drive v0.32
BeamNG.drive v0.32 release highlights
Festive Freight in BeamNG.drive v0.31
BeamNG.drive v0.31 release highlights
Gear Up for Fall Adventures in BeamNG.drive v0.30
BeamNG.drive v0.30 release highlights
Gambler 500 x BeamNG.drive - v0.29
BeamNG.drive v0.29 release highlights
Spring Renovations - BeamNG.drive v0.28
BeamNG.drive v0.28 release highlights
Conquer the desert in v0.27
BeamNG.drive v0.27 release highlights
BeamNG.drive v0.26 - Covet the Moment
BeamNG.drive v0.26 release highlights
BeamNG.drive v0.25 - Spark Your Passion
BeamNG.drive v0.25 release highlights
Festive Update v0.24.1 Released
BeamNG.drive v0.24.1 release highlights
The 2021 Winter Release – BeamNG.drive v0.24
BeamNG.drive v0.24 release highlights
The 2021 Summer Release – BeamNG.drive v0.23
BeamNG.drive v0.23 release highlights
The 2021 Spring Release – BeamNG.drive v0.22
BeamNG.drive v0.22 release notes
The 2020 Winter Release – BeamNG v0.21
BeamNG.drive v0.21 release notes
The 2020 Summer Release – BeamNG v0.20
BeamNG.drive v0.20 release notes
“La Vie à Toute Vitesse” – BeamNG.drive v0.19
BeamNG.drive v0.19 release notes
The 2019 Winter Release – BeamNG.drive v0.18
BeamNG.drive v0.18 release notes
Buckle up, heavy traffic ahead: Update 0.17 released
BeamNG.drive v0.17 release notes
Electrifying 0.16
BeamNG.drive v0.16 release notes
A Small Car on a Big Map – Version 0.15 released
BeamNG.drive v0.15 release notes
Light Runner – Version 0.14 Released
BeamNG.drive v0.14 release notes