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.35 Bug Reporting thread
    Solutions and more information may already be available.

Changing oil and coolant amount by console command

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Janusz_Alfa, Mar 18, 2022.

  1. Janusz_Alfa

    Janusz_Alfa
    Expand Collapse

    Joined:
    Mar 14, 2022
    Messages:
    15
    So, first thing first. When I execute dump(powertrain) I see that (sorry for screenshot, don't know how to copy text from console) oilMass is set to 3.48.
    dump-powertrain.jpg
    When I look at vehicle engine .jbeam file i see that oilVolume is set to 3:
    Code:
            //cooling and oil system
            "thermalsEnabled":true,
            "engineBlockMaterial":"iron",
            "oilVolume":3,
    
    And Im unsure why is that. If I asume that 1000ml of oil weights around 850g, then 3.5L of oil should weight around 3kg. But its switched around. 3L (oilVolume) of oil weights 3.5kg (oilMass)? Or Im not getting it right?

    Now to the point. Console dump shows a bunch of variables. Some of them I can change by executing:
    Code:
    powertrain.getDevice("mainEngine").thermals.headGasketBlown = true
    powertrain.getDevice("mainEngine").thermals.pistonRingsDamaged = true
    powertrain.getDevice("mainEngine").thermals.connectingRodBearingsDamaged = true
    powertrain.getDevice("mainEngine").thermals.exhaustTemperature = 500
    powertrain.getDevice("mainEngine").thermals.coolantTemperature = 130
    powertrain.getDevice("mainEngine").thermals.engineBlockTemperature = 130
    powertrain.getDevice("mainEngine").thermals.cylinderWallTemperature = 130
    powertrain.getDevice("mainEngine").thermals.oilTemperature = 130
    powertrain.getDevice("mainEngine").friction = 50
    powertrain.getDevice("mainEngine"):enable()
    powertrain.getDevice("mainEngine"):disable()
    
    And so on. An it works like a charm. But when i try to change oilMass or coolantMass in the same way nothing happens. No errors.
     
  2. Janusz_Alfa

    Janusz_Alfa
    Expand Collapse

    Joined:
    Mar 14, 2022
    Messages:
    15
    Ok so I found how the volume vs mass is calculated in combustionEngineThermals.lua, function initThermals. Initial value in liters is taken from vehicle engine jbeam data and placed into (table?) variable in kilograms:
    Code:
    fluidReservoirs.oil.currentMass = (jbeamData.oilVolume or 5) * 0.87
    And this SHOULD be corect, oil.Volume 3L * 0.87 should be calculated into oil.Mass 2.61kg. But the game somehow calculates it as oil.Volume 3L / 0.87 = oil.Mass 3.48. The other way around. It then displays it in both console an the engine thermal debug UI app, and probably uses the wrong number for calculations.

    Then after all calculations are done, it is written to the engineThermalData.oilMass which is accessible by powertrain.getDevice("mainEngine").thermals.oilMass, but the code does not read from it for calculations in the next loop. When I hardcoded it to be 0, it displayed 0 in game, but it wasn't using it for any calculations and car engine was working like normal. So inputting new number into above by console probably works, but its pointless because it immediately gets overwritten with new calculated value stored in fluidReservoirs.oil.currentMass, and this is the thing I should change.

    If I add a function inside combustionEngineThermals.lua then I can change it as I want and it gets used in all calculations and works like it should. But I have no clue how to do it from console command without modifying core files.

    And if I set it to 1kg, it sets it to 1kg without the liters-to-kilograms error. It displays it correctly in console and apps. This means the "3.48" error is not only a display error but its somewhere in the code, but again, piece of code quoted above seems ok.

    OK nevermind about the mass vs volume calculation. I was looking at the wrong engine. As it happens the engine I was using had exactly 4L which gave 3.48kg. 4L*0.87 gives 3.48 and 3L/0.87 gives close enough to 3.48. What a coincidence...
     
    #2 Janusz_Alfa, Mar 19, 2022
    Last edited: Mar 19, 2022
  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