1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.32 Bug Reporting thread
    Solutions and more information may already be available.

A couple of inconsistencies in vehicle Lua scripts

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Arcanox, Sep 29, 2021.

  1. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    I'm working on a fairly massive update to my Hybrid Core mod (and the related vehicle-specific mods). I've been getting pretty deep into some of the game's Lua systems while ironing out some issues with the hybrid powertrain. I have noticed two specific bugs so far within the game, one of which is really only an issue when communicating with the UI, but the other one is actually affecting powertrain calculations.

    I'll get the UI-related bug out of the way first. I brought this up in the BeamNG Discord server, but it quickly got drowned by other discussion:




    The second but has to do with the powertrain initialization.

    I have a custom Gearbox-type device that includes a built-in clutch (similar to the game's dctGearbox), and thus is "clutchlike" and has an "additionalEngineInertia" property. There is a physics-related value on my device that gets calculated with a different value immediately after a vehicle reload (Ctrl+R) than it does after any sort of recover/reset event (such as "I", "R" without Ctrl pressed, "Home", "Insert", etc). This means that the physical characteristics of this device are very slightly different when the vehicle is first spawned than they are if the vehicle is reset or recovered.

    I narrowed this bug down to the "inertia" property on the "combustionEngine" device. When my device calculates its value in the "calculateInertia" function, it uses the engine's inertia for part of the calculation. The engine's inertia has some specific value immediately after the vehicle is loaded, and if the vehicle is recovered or reset, that value gets smaller. I narrowed this down to the engine not accounting for its clutchChild's "additionalEngineInertia" value after a vehicle reset. In the combustionEngine's "validate" function, the inertia is adjusted using that value:

    Code:
    device.inertia = device.inertia + (device.clutchChild.additionalEngineInertia or 0)
    However, in the combustionEngine's "reset" function, that value is reset to the value from jbeamData and never adjusted again with the clutchChild's additionalEngineInertia:

    Code:
    device.inertia = jbeamData.inertia or 0.1
    The engine's "validate" function does not get called after a reset, so it doesn't add the additionalEngineInertia back in.
     
    #1 Arcanox, Sep 29, 2021
    Last edited: Oct 1, 2021
    • Like Like x 2
    • Staff Pick Staff Pick x 1
  2. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Nice one! The powertrain one will be fixed with the next big update :)
     
    • Like Like x 3
  3. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,062
    I knew something was wrong with the inertia, thanks for finding this, now I know exactly what!
     
    • Agree Agree 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