Solved Autobahn Traffic Rules

Discussion in 'World Editor' started by Grille, Jan 15, 2025.

  1. Grille

    Grille
    Expand Collapse

    Joined:
    Aug 17, 2019
    Messages:
    208
    • Like Like x 3
  2. Leo Zieger

    Leo Zieger
    Expand Collapse

    Joined:
    Jan 12, 2023
    Messages:
    826
    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.
     
  3. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    646
    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 :).
     
    #3 Barbent Servo GT, Jan 17, 2025
    Last edited: Jan 17, 2025
    • Like Like x 4
  4. Grille

    Grille
    Expand Collapse

    Joined:
    Aug 17, 2019
    Messages:
    208
    not sure it works

    Code:
    local M = {}
    
    local function onTrafficStarted() {
        gameplay_traffic.setTrafficVars({baseAggression = 0.6})
        gameplay_traffic.setTrafficVars({speedLimit = 100}) --m/s
    }
    
    M.onTrafficStarted = onTrafficStarted
    
    return M
    
     
  5. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    646
    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.
     
    • Like Like x 1
    • Agree Agree x 1
  6. Grille

    Grille
    Expand Collapse

    Joined:
    Aug 17, 2019
    Messages:
    208
    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
     
    #6 Grille, Jan 18, 2025
    Last edited: Jan 18, 2025
  7. MegaKnight

    MegaKnight
    Expand Collapse

    Joined:
    Sep 12, 2024
    Messages:
    202
    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
     
    • Like Like x 1
    • Agree Agree x 1
  8. Grille

    Grille
    Expand Collapse

    Joined:
    Aug 17, 2019
    Messages:
    208
    omfg lol, it works...
    to much c# i guess xD

    any idea what the variable for RespawnRate is called? (its not
    Code:
    respawnRate
    )
     
    • Like Like x 3
  9. MegaKnight

    MegaKnight
    Expand Collapse

    Joined:
    Sep 12, 2024
    Messages:
    202
    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
     
    • Like Like x 1
    • Agree Agree x 1
  10. Grille

    Grille
    Expand Collapse

    Joined:
    Aug 17, 2019
    Messages:
    208
    perfect, thank you verry much ^^
     
    • Like Like x 1
  11. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    646
    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.
     
    #11 Barbent Servo GT, Jan 18, 2025
    Last edited: Jan 18, 2025
  12. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    492
    I feel you!
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice