Expose more of the Turbocharger device in Lua

Discussion in 'Ideas and Suggestions' started by Arcanox, Sep 13, 2019.

  1. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    I'm experimenting with something that involves interacting directly with the turbocharger if there's one present on the vehicle. It seems like the Lua code for the turbocharger device uses file-local variables everywhere instead of storing state data on the device itself, which is making it impossible for me to accomplish what I'd like to.

    I'd like to see the turbo device become more like other devices where the state is stored as properties on the device table instead of inaccessible file locals. I can continue with my experimentation by modifying the turbocharger.lua file a little bit, but obviously can't ship anything that would rely on that.
     
    • Agree Agree x 1
    • Informative Informative x 1
  2. default0.0player

    default0.0player
    Expand Collapse

    Joined:
    Nov 30, 2018
    Messages:
    1,926
    I also found that the turbo simulation is not very realistic.
    Wastegate IRL is trying to maintain a constant boost pressure above the existing manifold pressure. Thus if you're at sea level and the boost is 1.5bar, the manifold pressure is 2.5bar. When you're at high elevation where the atmospheric pressure is 0.5bar, the manifold pressure would be 2.0bar, the engine only losts 20%power.Where an NA losts it's 50%power.
    However in BeamNG both turbo and NA engine lost the same 50% power if the atmospheric pressure is 0.5bar.
    BeamNGdrive-017119021-RELEASE-x642019_9_1322_17_13.png BeamNGdrive-017119021-RELEASE-x642019_9_1322_17_39.png
    The pictures above show that both turbocharged and N/A engine lose the same amount(about one third) torque at 2470 meters above sea level
     
    #2 default0.0player, Sep 13, 2019
    Last edited: Sep 13, 2019
    • Agree Agree x 1
    • Informative Informative x 1
  3. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    I wish it was possible / easier to have the powertrain devices work more like the turbo, but due to how they are creates, they are alle exposed.
    Having it not exposed is better for performance so if anything the powertrain stuff should change ;)
     
  4. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    I wouldn't think it would make a big difference in terms of performance if there's only one instance of the device. I would hate to see the values become less accessible; it makes it much harder to mod things. I'm thinking right now that since there's a field in the engine jBeam for "turbochargerLuaFileName", I could potentially ship a modified copy of the turbo that includes the minor changes I made, but it seems less-than-ideal to do that instead of having a way to access those values in the stock turbo.

    To give a little peek into what I'm doing, I'm playing around with attaching an electric motor onto the turbo on the Hybrid Bus so that it can pre-spool the turbo with the hybrid battery, as well as use excess turbo speed to regenerate a small bit of power in some cases (this is already something that happens in real life on Formula 1 cars :D ). I need a way to access and change the turbo's "curTurboAV" variable, plus data such as the turbo's inertia and maximum AV.
     
  5. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    That's what this is intended for, yes ;) As long as possible, it also won't break things as it's meant for that kind of usage, only if I ever need to change large parts of the turbo/engine interface this would probably end up breaking.

    No worries, the powertrain structure is like that for good reasons and there's no plan to change that.

    In general: Nice idea, however, the turbo is so messed up, I don't plan to spend any meaningful amounts of time there... Sorry
     
  6. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    Ok; I'll just go with the solution of shipping a modified version and I'll make sure to keep an eye on any major changes to the stock version so I can keep mine in sync as best possible :)
     
    • Like Like x 6
  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