Why power output reduce after reset?

Discussion in 'Programming' started by ArkFz, Mar 31, 2024.

  1. ArkFz

    ArkFz
    Expand Collapse

    Joined:
    Dec 24, 2023
    Messages:
    19
    I am designning a range extender which has mainly 2 parts: combustion engine and electric motor. The combustion engine powers up the electric motor, using regen to produce energy. Since BeamNG's powertrain doesn't allow us to connect 2 engine to 1 tree, I am using the rotator in the BeamNG to connect them.
    The system is working as I expected it is Init. However, once I pressed "R" to reset the vehicle, the power of the system reduces a lot. This won't happen if I use "CTRL+R" to reset.
    What's wrong with the system? How can I fix it? I would be appreciated to get the answer.
     
    • Like Like x 1
  2. SiC_IGCT

    SiC_IGCT
    Expand Collapse

    Joined:
    Mar 31, 2024
    Messages:
    1
    try copying init function and renaming it to reset?
    我也是lua小白,不保证以上方法能行XD
     
  3. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    282
    When you press 'R' to reset, this gets called: "onVehicleReset" (lua/vehicle/main.lua:425). This will reset everything, so I suppose that's why it reduces the power. You could maybe copy this file and put it in your mod and modify it a bit, but it could cause issues for you with future updates since you're overriding it. Another idea actually, I'm not exactly sure what's being reset, but in the "if not initCalled" scope, there's a bunch of resets. Figure out which one is causing the issue, and maybe override that specific extension.
     
  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