WIP Beta released Advanced Dynamic Steering - V0.0.2

Discussion in 'Utilities and programming' started by bits&bytes, Sep 23, 2013.

  1. bits&bytes

    bits&bytes
    Expand Collapse

    Joined:
    Jun 13, 2013
    Messages:
    40
    Information:
    With this modification you can modify the speed of the steering wheel for keyboard playing.

    From version 0.0.0
    :
    By pressing "ctrl s" (by default) a GUI pop's up where you can change following parameters:

    • In rate: The steering rate towards the center while pressing a steering key (for example steering left and then immediately press the right key).
    • Out rate: The steering rate away from the center.
    • Auto Center Rate: The rate at which the steering wheel turns towards the center while releasing the steering keys

    Parameters that are left blanco or where no numeric value is entered, will stay at the actual value.

    From version 0.0.1:
    Parameters can be saved to and loaded from a .uc file (User Configuration). The files have by default a 'ADS_' prefix.
    Every time the game is started, a file named 'ADS_Original.uc' will be created. This file contains the original settings. So you can go back to the original values at every time, by loading this file.
    Parameter changings become only effective after pressing the ‘ok’ button. So after changing, saving or loading, you must press ‘ok’ to apply the changed parameters to the dynamic steering.

    From version 0.0.2:
    5 additional parameters can be set on the GUI. These parameters can be applied immediately during driving, by holding one of the numeric key's 1 to 5.
    The dynamic parameters (the first 3 on the GUI) can not be set to 0 due to a program restriction which I could not yet find a solution to.

    Thanks to GregBlast and Incognito for the GUI tutorial and for all the advices.

    Change log:

    • Version 0.0.0, (23-sep-2013):
      • First version.
    • Version 0.0.1, (30-sep-2013):
      • Replaced ‘original was’ by ‘actual:’ at the descriptions of the parameters into the GUI.
      • Adding save and load functionality.
      • Changed steering parameters are now maintained after reloading the vehicle or restarting the game.
      • Moved most code to SteeringParametersGUI.lua so there are fewer modifications to the original input.lua.

    • Version 0.0.2, (08-oct-2013):
      • Adding 15 more parameters to the GUI divided into 5 sets. These sets can be called using the numeric keys 1 to 5.

    Installation
    :

    By BeamNG Lua-mod Installer.If using Lua-mod installer then beware of these issues:


    • If your game already contains version 0.0.0 of this mod, you must first uninstall it (or run BeamNG- Updater to go back to the original files) before BeamNG Lua-mod Installer.

    • On my laptop, the replacing of the strings is not working by the Lua-mod installer. So check file [game path]\lua\vehicle\ input.lua .
      Search for string smootherKBD = newTemporalSmoothing(M.kbdInRate * rateMult, M.kbdOutRate * rateMult, M.kbdAutoCenterRate * rateMult, 0),. If not found, then search for smootherKBD = newTemporalSmoothing(kbdInRate * rateMult, kbdOutRate * rateMult, kbdAutoCenterRate * rateMult, 0) and replace it by the above string (place M. before the kbd... variables).
    • utils.lua can not be modified using the lua-mod installer because there are to many similar strings into the code.
    • beamng.cs can not be modified using the lua-mod installer (adding after a function is only possible in LUA code).

    Or manualy:

    • Copy SteeringParametersGUI.lua to [game path]\lua\vehicle\
    • Add following code (in blue) into [game path]\lua\vehicle\ default.lua :
    Code:
    require("utils")
    canvas     = require("canvas")
    drivetrain = require("drivetrain")
    sounds     = require("sounds")
    bdebug     = require("bdebug")
    input      = require("input")
    props      = require("props")
    beamng     = require("beamng")
    particlefilter = require("particlefilter")
    particles  = require("particles")
    material   = require("material")
    electrics  = require("electrics")
    json       = require("json")
    beamstate  = require("beamstate")
    sensors    = require("sensors")
    bullettime = require("bullettime")
    thrusters  = require("thrusters")
    hydros     = require("hydros")
    inputwizard = require("inputwizard")
    perf       = require("perf")
    partmgmt   = require("partmgmt") -- do not change its name, the GUI callback will break otherwise
    [COLOR=#0000ff]SteeringParametersGUI = require("SteeringParametersGUI") -- Mod by bits&bytes on 19/sep/2013[/COLOR]
     
    

    • Add following code (in blue) from [game path]\lua\vehicle\ input.lua :
    Code:
    local function init()
                    --scale rates based on steering wheel degrees
                    if hydros then
                                   for _, h in pairs (hydros.hydros) do
                                                   --check if it's a steering hydro
                                                   if h.inputSource == "steering_input" then
                                                                   --if the value is present, scale the values
                                                                   if h.steeringWheelLock then
                                                                                  rateMult = 450 / math.abs(h.steeringWheelLock)
                                                                                  break
                                                                   end
                                                   end
                                   end
                    end
     
                    if rateMult == nil then
                                   rateMult = 5/8
                    end
     
                    --inRate (towards the center), outRate (away from the center), autoCenterRate, startingValue[COLOR=#0000cd] -- Mod by bits&bytes on 25/sep/2013: kbd... by M.kbd...[/COLOR]
                    M.state = { 
                                   axisx0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing([B][COLOR=#0000cd]M.[/COLOR][/B]kbdInRate * rateMult,[COLOR=#0000cd] [B]M.[/B][/COLOR]kbdOutRate * rateMult, [COLOR=#0000ff][B]M.[/B][/COLOR]kbdAutoCenterRate * rateMult, 0), 
                                                   smootherPAD = newTemporalSmoothingNonLinear(padInRate * rateMult, padOutRate * rateMult, nil, 0), 
                                                   minLimit = -1, maxLimit = 1, binding = "steering" },
                                   axisy0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "throttle" },
                                   axisy1 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "brake" },
                                   axisy2 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "parkingbrake" },
                                   axisy3 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "clutch" },
                                   }
    end
     
    And:

    Code:
    -- public interface
    M.update = update
    M.init = init
    M.reset = reset
    M.toggleParkingbrake = toggleParkingbrake
    M.processRawEvent = processRawEvent
    M.mapsReloaded = mapsReloaded
    M.toggleDynamicSteering = toggleDynamicSteering
    M.event = event
    M.toggleEvent = toggleEvent
    [COLOR=#0000ff]M.kbdInRate = kbdInRate
    M.kbdOutRate = kbdOutRate
    M.kbdAutoCenterRate = kbdAutoCenterRate
    [/COLOR] 
    return M
    

    If you already changed this file according to a previous version of this mod, then you must also remove the lines which you added according to the previous version.


    • Add following code (in blue) into [game path]\scripts\client\inputmaps\keyboard.inputmap.cs:

    Code:
    ////////////////////////////////////////////////
    //// Vehicle Keyboard mappings
    
    %mm.bind( keyboard, a, moveleft );
    %mm.bind( keyboard, d, moveright );
    %mm.bind( keyboard, w, moveforward );
    %mm.bind( keyboard, s, movebackward );
    
    %mm.bind( keyboard, left, steer_left );
    %mm.bind( keyboard, right, steer_right );
    %mm.bind( keyboard, up, accelerate );
    %mm.bind( keyboard, down, brake );
    [COLOR=#0000ff]%mm.bind( keyboard, 1, steering_set1 ); //mod by bits&bytes on 08 oct 2013
    %mm.bind( keyboard, 2, steering_set2 ); //mod by bits&bytes on 08 oct 2013
    %mm.bind( keyboard, 3, steering_set3 ); //mod by bits&bytes on 08 oct 2013
    %mm.bind( keyboard, 4, steering_set4 ); //mod by bits&bytes on 08 oct 2013
    %mm.bind( keyboard, 5, steering_set5 ); //mod by bits&bytes on 08 oct 2013[/COLOR]
    
    // shifting 
     
    And:

    Code:
    // assorted
    %mm.bindCmd(keyboard, i, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, r, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, j, "beamNGTogglePhysics();", "");
    %mm.bind(keyboard, p, parkingbrake_toggle);
    %mm.bindCmd(keyboard, "ctrl r", "beamNGReloadCurrentVehicle();", "");
    %mm.bindCmd(keyboard, "shift t", "beamNGReloadSystemLua();", "");
    %mm.bindSLuaCmd(keyboard, "ctrl t", "showAIGUI()", "");
     
    %mm.bindCmd(keyboard, "ctrl e", "Canvas.pushDialog(VehicleChooser);", "");
    %mm.bindVLuaCmd(keyboard, "ctrl w", "partmgmt.showGUI()", "");
    [COLOR=#0000cd]%mm.bindVLuaCmd(keyboard, "ctrl s", "SteeringParametersGUI.showGUI()", ""); // mod by bits&bytes on 22/sep/2013[/COLOR]
     
     
    Add following code (in blue) into [game path]\scripts\client\beamng.cs:

    Code:
    // helper variables for the keyboard steering
    $keybdSteerStateLeft = 0;
    $keybdSteerStateRight = 0;
    
    function steer_left( %val, %inputType ) {
       $keybdSteerStateLeft = %val;
       // check if the other arrow key is still pressed
       if(%val == 0 && $keybdSteerStateRight == 1)
       {
          steer_right(1, %inputType);
          return;
       }
    
       vlua("input.event(\'axisx0\', " @ -%val @ ", " @ %inputType @ ")");
    }
    
    function steer_right( %val, %inputType ) {
       $keybdSteerStateRight = %val;
       // check if the other arrow key is still pressed
       if(%val == 0 && $keybdSteerStateLeft == 1)
       {
          steer_left(1, %inputType);
          return;
       }
    
       vlua("input.event(\'axisx0\', " @ %val @ ", " @ %inputType @ ")");
    }
    
    [COLOR=#0000ff]//function added by bits&bytes on 08-oct-2013:
    function steering_set1( %val, %inputType ) {
       vlua("SteeringParametersGUI.Steering_set1(" @ %val @ ")");
    }
    
    //function added by bits&bytes on 08-oct-2013:
    function steering_set2( %val, %inputType ) {
       vlua("SteeringParametersGUI.Steering_set2(" @ %val @ ")");
    }
    
    //function added by bits&bytes on 08-oct-2013:
    function steering_set3( %val, %inputType ) {
       vlua("SteeringParametersGUI.Steering_set3(" @ %val @ ")");
    }
    
    //function added by bits&bytes on 08-oct-2013:
    function steering_set4( %val, %inputType ) {
       vlua("SteeringParametersGUI.Steering_set4(" @ %val @ ")");
    }
    
    //function added by bits&bytes on 08-oct-2013:
    function steering_set5( %val, %inputType ) {
       vlua("SteeringParametersGUI.Steering_set5(" @ %val @ ")");
    }
    [/COLOR]
    function steer( %val, %inputType ) {
       vlua("input.event(\'axisx0\', " @ %val @ ", " @ %inputType @ ")");
    }
    
    Add following code (in blue) from [game path]\lua\utils.lua :

    Code:
    function temporalSmoothing:get(sample, dt)
        local rate
        local dir = (sample - self.state) * sign(self.state)
    [COLOR=#0000ff]    local factor_inRate = 1 -- mod by bits&bytes on 08-oct-2013
        local factor_outRate = 1 -- mod by bits&bytes on 08-oct-2013
        local factor_acRate = 1 -- mod by bits&bytes on 08-oct-2013
        
        -- Define factor-values for extended steering (if nill then 1): -- mod by bits&bytes on 08-oct-2013
        if SteeringParametersGUI.factor_inRate then 
            factor_inRate = SteeringParametersGUI.factor_inRate 
        end
        if SteeringParametersGUI.factor_outRate then 
            factor_outRate = SteeringParametersGUI.factor_outRate 
        end
        if SteeringParametersGUI.factor_acRate then 
            factor_acRate = SteeringParametersGUI.factor_acRate 
        end
        ------------------------------------------------------------------------------------------------
    [/COLOR]
        -- autocentering
        if self.autoCenterRate ~= nil and sample == 0 then
            rate = self.autoCenterRate[COLOR=#0000ff] * factor_acRate[COLOR=#0000ff] -- mod by bits&bytes on 08-oct-2013[/COLOR][/COLOR]
        else
            if dir >= 0 then
                rate = self.outRate[COLOR=#0000ff] * factor_outRate[COLOR=#0000ff] -- mod by bits&bytes on 08-oct-2013[/COLOR][/COLOR]
            else
                rate = self.inRate[COLOR=#0000ff] * factor_inRate -- mod by bits&bytes on 08-oct-2013[/COLOR]
            end
        end
    
        if sample < self.state then
            self.state = math.max(self.state - dt * rate, sample)
        else
            self.state = math.min(self.state + dt * rate, sample)
        end
    
        return math.max(math.min(self.state, 1), -1)
    end
    
    
    Future plans:

    • Adding the ability to save the parameters to a file: Done in V 0.0.1
    • Place the actual values automatically in the input fields while opening the GUI (don’t know how to do that yet): On Hold
    • Adding parameters for emergency steering (= steering while pressing “ctrl left (or right)”. For example when faster steering is required): Alternative in V 0.0.2
    • Adding incremental steering mode: Steering wheel stay’s in its position after releasing the steering key’s and turns back to the center after pressing the release key (“numpad 0” by default): Alternative in V 0.0.2
    • Adding some S-curve to the steering (so steering wheel starts slow and goes faster while holding the steering key, and eventually slows down before reaching maximum.
    • Make the steering rate slower (or faster if desired) when air speed increases.
     

    Attached Files:

    #1 bits&bytes, Sep 23, 2013
    Last edited: Oct 8, 2013
  2. JoeDirtThe3rd

    JoeDirtThe3rd
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    34
    Re: Advanced Dynamic Steering

    anyone using a keyboard should give this a try! actually seems very good for dynamic steering! I use a g27 so it really doesn't have a lot of use for me, but this is pretty cool! good job!
     
  3. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Advanced Dynamic Steering

    Nice. I'm not really using keyboard but sometimes for drifting tests for example. This really makes the difference.

    I see you used the 'input' module as it was with a simple way to update it. That's a good way to do it. I would just recommand that you put the least you need in the original modules. And would avoid making globals when possible. Here to keep as much out as possible you could simply expose the variables to the 'input' public interface and do your jobs on 'em within your module (by requiring 'input' there first so you can use it).
     
  4. bits&bytes

    bits&bytes
    Expand Collapse

    Joined:
    Jun 13, 2013
    Messages:
    40
    Re: Advanced Dynamic Steering

    Tanks for the positive reactions.
    I am currently busy with the save / load part, so you can save and load different parameter sets.
    A Known issue is the fact that if you reload your car ("ctrl r", "r", or "i" by default) or restart the game, you always go back to the original parameters. This should be solved in the next update.

    Thanks for these recommendations. I already moved some of my code to my module. The only changes in input.lua are now the kbd...Rate variables added to the public interface and used in the input() function. I will also try to change my global variables to public ones.
     
  5. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Advanced Dynamic Steering

    Good :). As for the values reset on reload when you'll have your code for loading / saving just also save the last used one and load it on reload (which mean when 'default.lua' is executed). So basically you would do that in your module OUTSIDE of a function (or make a local function and immediately call it).
     
  6. bits&bytes

    bits&bytes
    Expand Collapse

    Joined:
    Jun 13, 2013
    Messages:
    40
    Re: Advanced Dynamic Steering - V0.0.1

    I just uploaded a new version.
    Parameters can now be saved into a file. The last made changes will always be saved and loaded automatic when restarting the game. So now the changes are maintained after restarting the game or reloading the car.
    Also, at every start of the game, all original parameters are written to a file 'ADS_Original.uc'. So you can go always back to the original settings by loading that file.

    About the files, I choosed for '.uc' (User Configuration) as file extension. This is more universal. But I added a prefix 'ADS_' (Advanced Dynamic Steering) to the files.
    For loading a file, I have added the prefix to the fille filter, so by default you only see the ADS_*.uc files.
    The files are placed under [game path]\lua\vehicle\ input.lua for now. Don't know if this is the right place for it, because after every official update, they will be removed.
    So its best to make a backup of these files, so you can place them back after an official update.

    I also moved most modified code from input.lua to my file 'SteeringParametersGUI.lua'.

    When updating from version 0.0.0 to 0.0.1 you must first uninstall the previous version, (or you can first run the updater again to start with a fresh unmodded game):
    • Delete following code (in red) from [game path]\lua\vehicle\ default.lua :
    Code:
    require("utils")
    canvas     = require("canvas")
    drivetrain = require("drivetrain")
    sounds     = require("sounds")
    bdebug     = require("bdebug")
    input      = require("input")
    props      = require("props")
    beamng     = require("beamng")
    particlefilter = require("particlefilter")
    particles  = require("particles")
    material   = require("material")
    electrics  = require("electrics")
    json       = require("json")
    beamstate  = require("beamstate")
    sensors    = require("sensors")
    bullettime = require("bullettime")
    thrusters  = require("thrusters")
    hydros     = require("hydros")
    inputwizard = require("inputwizard")
    perf       = require("perf")
    partmgmt   = require("partmgmt") -- do not change its name, the GUI callback will break otherwise
    [COLOR=#ff0000]SteeringParametersGUI = require("SteeringParametersGUI") -- Mod by bits&bytes on 19/sep/2013[/COLOR]
     
    

    • Delete following code (in red) from [game path]\lua\vehicle\ input.lua :
    Code:
    local function init()
                    --scale rates based on steering wheel degrees
                    if hydros then
                                   for _, h in pairs (hydros.hydros) do
                                                   --check if it's a steering hydro
                                                   if h.inputSource == "steering_input" then
                                                                   --if the value is present, scale the values
                                                                   if h.steeringWheelLock then
                                                                                  rateMult = 450 / math.abs(h.steeringWheelLock)
                                                                                  break
                                                                   end
                                                   end
                                   end
                    end
     
                    if rateMult == nil then
                                   rateMult = 5/8
                    end
     
                    --inRate (towards the center), outRate (away from the center), autoCenterRate, startingValue
                    M.state = { 
                                   axisx0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(kbdInRate * rateMult, kbdOutRate * rateMult, kbdAutoCenterRate * rateMult, 0), 
                                                   smootherPAD = newTemporalSmoothingNonLinear(padInRate * rateMult, padOutRate * rateMult, nil, 0), 
                                                   minLimit = -1, maxLimit = 1, binding = "steering" },
                                   axisy0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "throttle" },
                                   axisy1 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "brake" },
                                   axisy2 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "parkingbrake" },
                                   axisy3 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "clutch" },
                                   }
    end
     
    [COLOR=#ff0000]-- Copy these local variables to global ones to make them available in a user GUI:
    Par_kbdInRate = kbdInRate -- Mod by bits&bytes on 20/sep/2013
    Par_kbdOutRate = kbdOutRate -- Mod by bits&bytes on 20/sep/2013
    Par_kbdAutoCenterRate = kbdAutoCenterRate -- Mod by bits&bytes on 20/sep/2013
     
    -- Update the steering variables with the ones from the user GUI:
    local function UpdateSteeringParameters() -- Mod by bits&bytes on 20/sep/2013: function added
                    kbdInRate = Par_kbdInRate       
                    kbdOutRate = Par_kbdOutRate                
                    kbdAutoCenterRate = Par_kbdAutoCenterRate                                              
                    init()
    end
    [/COLOR]
    And:

    Code:
    -- public interface
    M.update = update
    M.init = init
    M.reset = reset
    M.toggleParkingbrake = toggleParkingbrake
    M.processRawEvent = processRawEvent
    M.mapsReloaded = mapsReloaded
    M.toggleDynamicSteering = toggleDynamicSteering
    M.event = event
    M.toggleEvent = toggleEvent
    [COLOR=#ff0000]M.UpdateSteeringParameters = UpdateSteeringParameters -- Mod by bits&bytes on 20/sep/2013[/COLOR]
     
    return M
    

    • Delete following code (in red) from [game path]\scripts\client\inputmaps\keyboard.inputmap.cs:
    Code:
    // assorted
    %mm.bindCmd(keyboard, i, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, r, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, j, "beamNGTogglePhysics();", "");
    %mm.bind(keyboard, p, parkingbrake_toggle);
    %mm.bindCmd(keyboard, "ctrl r", "beamNGReloadCurrentVehicle();", "");
    %mm.bindCmd(keyboard, "shift t", "beamNGReloadSystemLua();", "");
    %mm.bindSLuaCmd(keyboard, "ctrl t", "showAIGUI()", "");
     
    %mm.bindCmd(keyboard, "ctrl e", "Canvas.pushDialog(VehicleChooser);", "");
    %mm.bindVLuaCmd(keyboard, "ctrl w", "partmgmt.showGUI()", "");
    [COLOR=#ff0000]%mm.bindVLuaCmd(keyboard, "ctrl s", "SteeringParametersGUI.showGUI()", ""); // mod by bits&bytes on 22/sep/2013[/COLOR]
     
     
    The new configuration files (SteeringParametersGUI.lua and the Lua-Mod installer file) are into the first post of this topic.
     
    #6 bits&bytes, Sep 30, 2013
    Last edited: Sep 30, 2013
  7. kittyfluffins

    kittyfluffins
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    2
    Re: Advanced Dynamic Steering - V0.0.1

    Thank you for making this! I look forward to the future plans. It seems absolutely required for those of us using keyboards (or controllers that are mapping to keyboard keys). No more lightly tapping keys to turn a fast vehicle. Repeatedly jerking the wheel to the left or the right is not a good way to turn in a car going 70 mph. I can actually handle the civetta bolide now that I'm only repeatedly slamming on the gas.
     
  8. bits&bytes

    bits&bytes
    Expand Collapse

    Joined:
    Jun 13, 2013
    Messages:
    40
    I 'm about to release version 0.0.2 of this mod.
    This version adds 5 additional parameter sets which you can change by the GUI and which you can call by pushing the numeric keys 1 to 5 (the ones on the upper side of the keyboard, below the F-keys).
    So by holding key '1' the steering wheel will turn with the speed of the 'Steering set1:' parameters of the GUI. Releasing all numeric keys (1 to 5) will apply the Dynamic Steering parameters of the GUI.

    You can also put the Auto Center parameter on the set1 to set5 parameters to 0. In that case the steering wheel stays in its position while holding the corresponding numeric key, after releasing the steering key's.

    Putting one of the Dynamic Steering parameters to 0, will not work due to a restriction into the program code (dividing by 0).

    The installation off this version might be a little more difficult because a few more file's are affected and not all changes can be done by Lua mod installer.

    When updating from version 0.0.1 to 0.0.2, using lua mod installer, you must first uninstall the previous version, (or you can first run the updater again to start with a fresh unmodded game):

    • Delete following code (in red) into [game path]\lua\vehicle\ default.lua :
    Code:
    require("utils")
    canvas     = require("canvas")
    drivetrain = require("drivetrain")
    sounds     = require("sounds")
    bdebug     = require("bdebug")
    input      = require("input")
    props      = require("props")
    beamng     = require("beamng")
    particlefilter = require("particlefilter")
    particles  = require("particles")
    material   = require("material")
    electrics  = require("electrics")
    json       = require("json")
    beamstate  = require("beamstate")
    sensors    = require("sensors")
    bullettime = require("bullettime")
    thrusters  = require("thrusters")
    hydros     = require("hydros")
    inputwizard = require("inputwizard")
    perf       = require("perf")
    partmgmt   = require("partmgmt") -- do not change its name, the GUI callback will break otherwise
    [COLOR=#ff0000]SteeringParametersGUI = require("SteeringParametersGUI") -- Mod by bits&bytes on 19/sep/2013[/COLOR]
     
    

    • Delete following code (in red) from [game path]\lua\vehicle\ input.lua :
    Code:
    local function init()
                    --scale rates based on steering wheel degrees
                    if hydros then
                                   for _, h in pairs (hydros.hydros) do
                                                   --check if it's a steering hydro
                                                   if h.inputSource == "steering_input" then
                                                                   --if the value is present, scale the values
                                                                   if h.steeringWheelLock then
                                                                                  rateMult = 450 / math.abs(h.steeringWheelLock)
                                                                                  break
                                                                   end
                                                   end
                                   end
                    end
     
                    if rateMult == nil then
                                   rateMult = 5/8
                    end
     
                    --inRate (towards the center), outRate (away from the center), autoCenterRate, startingValue[COLOR=#ff0000] -- Mod by bits&bytes on 25/sep/2013: kbd... by M.kbd...[/COLOR]
                    M.state = { 
                                   axisx0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing([COLOR=#ff0000][B]M.[/B][/COLOR]kbdInRate * rateMult,[COLOR=#0000cd] [/COLOR][COLOR=#ff0000][B]M.[/B][/COLOR][COLOR=#0000cd][/COLOR]kbdOutRate * rateMult, [COLOR=#ff0000][B]M.[/B][/COLOR]kbdAutoCenterRate * rateMult, 0), 
                                                   smootherPAD =  newTemporalSmoothingNonLinear(padInRate * rateMult, padOutRate *  rateMult, nil, 0), 
                                                   minLimit = -1, maxLimit = 1, binding = "steering" },
                                   axisy0 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "throttle" },
                                   axisy1 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "brake" },
                                   axisy2 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "parkingbrake" },
                                   axisy3 = { val = 0, inputType = 0, 
                                                   smootherKBD = newTemporalSmoothing(3, 3, 5, 0), 
                                                   smootherPAD = newTemporalSmoothing(10, 10, nil, 0), 
                                                   minLimit =  0, maxLimit = 1, binding = "clutch" },
                                   }
    end
     
    And:

    Code:
    -- public interface
    M.update = update
    M.init = init
    M.reset = reset
    M.toggleParkingbrake = toggleParkingbrake
    M.processRawEvent = processRawEvent
    M.mapsReloaded = mapsReloaded
    M.toggleDynamicSteering = toggleDynamicSteering
    M.event = event
    M.toggleEvent = toggleEvent
    [COLOR=#ff0000]M.kbdInRate = kbdInRate
    M.kbdOutRate = kbdOutRate
    M.kbdAutoCenterRate = kbdAutoCenterRate[/COLOR][COLOR=#0000ff]
    [/COLOR] 
    return M
    

    If you already changed this file according to version 0.0.1 or 0.0.0 of this mod, then you must also remove the lines which you added according to the previous version.


    • Delete following code (in red) into [game path]\scripts\client\inputmaps\keyboard.inputmap.cs:
    Code:
    // assorted
    %mm.bindCmd(keyboard, i, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, r, "beamNGResetPhysics();", "");
    %mm.bindCmd(keyboard, j, "beamNGTogglePhysics();", "");
    %mm.bind(keyboard, p, parkingbrake_toggle);
    %mm.bindCmd(keyboard, "ctrl r", "beamNGReloadCurrentVehicle();", "");
    %mm.bindCmd(keyboard, "shift t", "beamNGReloadSystemLua();", "");
    %mm.bindSLuaCmd(keyboard, "ctrl t", "showAIGUI()", "");
     
    %mm.bindCmd(keyboard, "ctrl e", "Canvas.pushDialog(VehicleChooser);", "");
    %mm.bindVLuaCmd(keyboard, "ctrl w", "partmgmt.showGUI()", "");
    [COLOR=#ff0000]%mm.bindVLuaCmd(keyboard, "ctrl s", "SteeringParametersGUI.showGUI()", ""); // mod by bits&bytes on 22/sep/2013[/COLOR]
     
     
    The new configuration files (SteeringParametersGUI.lua and the Lua-Mod installer file) are into the first post of this topic.
     
  9. riadh☻••

    riadh☻••
    Expand Collapse

    Joined:
    Nov 28, 2013
    Messages:
    2
    Not to be rude, but i`m new to BeamNg Drive and I don`t really know how to enter in codes at the moment. So... maybe a video would help. :D
     
  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