Jump to content

Vehicles.lua - small mistake in code of fuel usage


Tread

Recommended Posts

Version 41.65
Rest is not relevant since report regards lua code.

 

Issue is regarding vehicle fuel consumption - gasMultiplier increased by heater usage should result in more Gas being used from gas tank. At the moment it does the opposite. Even variable name is opposite to what is done with it in line 368 - it is being used as denominator. Effectively reducing fuel consumption the higher it is (and as you see in line 342 heater usage increases it).

Bottom line is that turning heater ON lowers the fuel consumption of vehicle. My tests (while playing with values in code) also do confirm that.

 

server/Vehicles/Vehicles.lua
line 342:
        if heater and heater:getModData().active then
            gasMultiplier = gasMultiplier + 5000;
        end

line 368:

        local newAmount = (speedMultiplier / gasMultiplier)  * SandboxVars.CarGasConsumption;
        newAmount =  newAmount * (vehicle:getEngineSpeed()/2500.0);
        amount = amount - elapsedMinutes * newAmount;

 

 

I found the issue while working on my mod and studying game lua files.
I hope that this finding (even thought it is minor issue) will help!

P.S. Apologies for not using "code" formatting, but it bugged out for some reason and I could not use it in this post.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...