I would like to setup traffic for my map: https://www.beamng.com/threads/autobahn-57k.102500/ How (if at all possible) do I setup: Overtaking only from the left Cars going to the most right lane that’s free. Make the ai drive as fast as possible
From what I have observed of AI driving they take one lane and stay on it (except if they are too fast in a corner and so come to another lane). So I don´t think 1) and 2) is possible. As fast as possible: even with wide lanes the AI speed limit will always be default 120. You can see this if you have Zeit´s simple AI limit UI mod installed. But maybe there is some LUA code that can overrule this.
I have placed some code in my mainLevel.lua that overrides the normal AI behaviour with positive effect (more speed). I set the baseAggression to 0.6 and the speedLimit to 360km/h (what is maximum). Code: gameplay_traffic.setTrafficVars({baseAggression = 0.6}) gameplay_traffic.setTrafficVars({speedLimit = 100}) --m/s The code is executed on the onTrafficStarted() event (callback function). Maybe this can work for you, too .
not sure it works Spoiler: Is this correct? Code: local M = {} local function onTrafficStarted() { gameplay_traffic.setTrafficVars({baseAggression = 0.6}) gameplay_traffic.setTrafficVars({speedLimit = 100}) --m/s } M.onTrafficStarted = onTrafficStarted return M
That seems to be correct. You could insert the following line: Code: log('I', "Grille Test") to have a feedback written into the log file if it gets called. --- Post updated --- A speedLimit of 360km/h does not mean AI will drive that fast. It only deletes the limit. Other factors are roadwidth and curve radius. Also if the speed gets higher new AI cars are spawned in front of you with zero starting speed and have to accelerate first and thus push down the whole AI speed.
ok changing the variables manually with the ui app works. but i cant get this script to work, not even the log messages show up... Auto: Off Speed: 300 Respawn: 0.25 Risk: 2 The values work great
You wrote your function inside these brackets {}. I think that doesn't work. Try to remove them and write "end" at the end of your function instead. Like this: Code: local function onTrafficStarted() gameplay_traffic.setTrafficVars({baseAggression = 0.6}) gameplay_traffic.setTrafficVars({speedLimit = 100}) --m/s end
omfg lol, it works... to much c# i guess xD any idea what the variable for RespawnRate is called? (its not Code: respawnRate )
I think it's Code: spawnValue The setTrafficVars function is located here, so you can take a look yourself: BeamNG.drive/lua/ge/extensions/gameplay/traffic.lua
BTW: The funcion onTrafficStarted() is only called once. Try the "Toggle Traffic" keybind. The first time you start traffic the variables are set. After that toggling traffic off/on only respawns the vehicles and the function is not called again.