Rivens Realistic Train Acceleration (based on cargo) - Space Age


This mod makes train acceleration more realistic and depend on the amount of Cargo. (youtube demo included)

Tweaks
8 days ago
1.1 - 2.1
3.93K
Trains

i [solved] Effect Options

11 days ago
(updated 11 days ago)

Hi,

I wanted to use your mod in Factorio 2.1, so I extracted it and simply updated the version number. It works great!

While playing with quality electric trains, I felt that the acceleration and top speed were a bit too restrictive for my taste. I looked for settings to tweak the train physics but couldn't find any, so I experimented by adding a few configurable multipliers myself.

For example:

-- Factor
-- 1.0 = original physics
-- <1.0 = weaker physics restrictions (faster trains)
-- >1.0 = stronger physics restrictions (slower trains)
-- Must be > 0
local PHYSICS_EFFECT_SPEED = 0.33
local PHYSICS_EFFECT_ACCELERATION = 1.5
local PHYSICS_EFFECT_BRAKE = 0.8

Applied here:

return engine_power / math.max(speed, 0.1) / PHYSICS_EFFECT_SPEED
return force / mass / PHYSICS_EFFECT_ACCELERATION
return MAX_BRAKE_DECELERATION / PHYSICS_EFFECT_BRAKE

With all values set to 1.0, the mod behaves exactly as it does now, so this wouldn't change the default gameplay. Players who prefer a different balance could simply adjust the settings to their liking.

I thought this might make a nice addition as startup or map settings. It may not be perfectly realistic, but it would give players a simple way to customize the train physics without having to edit the mod files.

Thanks again for making the mod!

EDIT:
While experimenting I also noticed that SLOW_START_THRESHOLD and SLOW_START_POWER nearly disappeared with my changes to the acceleration.

I ended up adding another multiplier:

local SLOW_START_TRACTION = 0.25

And added it here:

if speed < SLOW_START_THRESHOLD then
    local ratio = speed / SLOW_START_THRESHOLD
    ratio = math.pow(ratio, SLOW_START_POWER)
    ratio = ratio * SLOW_START_TRACTION -- added
    force = force * math.max(ratio, 0.01)
end

This is just me experimenting with the values. You probably have a better idea of how to achieve higher cruising speeds over medium distances while keeping the physics balanced, since you know the code much better than I do. Thanks again for your work on the mod!

8 days ago
(updated 8 days ago)

Hey Schuby! Thanks for the suggested changes. I have update the mod, see v0.1.27

As for your suggestions, please note that there are only 2 factors/multipliers that can affect acceleration/braking.
You introduced PHYSICS_EFFECT_SPEED and PHYSICS_EFFECT_ACCELERATION, but if you trace the effects of both through the code, you effective end up with:

return ... / PHYSICS_EFFECT_SPEED / PHYSICS_EFFECT_ACCELERATION

So you're using 2 variables to change 1 thing, in the same manner.

I transformed your suggestion to these user-adjustable multipliers:
- ENGINE_POWER_MULTIPLIER
- BRAKE_FORCE_MULTIPLIER
- SLOW_START_MULTIPLIER
the naming should be self-explanatory.

While I was at it: I also fixed braking - it now depends on carriage-count (each carriage has a brake, like IRL) and calculated train mass.

I think the end-result is reasonably balanced - please notify me if something (in your specific set of mods) feels off, or... broke.

6 days ago

Sounds great! Will try it later.
Thanks a lot for implementing it.

6 days ago
(updated 6 days ago)

Feels very smooth overall in all different settings.
I even found a new favorite, really low break force with high engine power gives it a more "let it roll" feeling.
I will try a bit more with heavy cargo in future. (Tested with 1:1 electric trains)

Only thing i noticed with lowest engine power and lowest slow start it does the stutter sound, but it does accelerate after some time as it should. So i think it is totally fine.

6 days ago

Thanks for testing it. I will look into it, but cannot promise anything :) Allowing players to tweak settings explodes the number of things to test, which is already quite high, with all the mods and how they interact.

The next update will feature realistic braking for red rail-signals and trains get affected by curved rails too. I'm currently on the fence whether trains should brake ahead of curves, or get into them at regular speeds and then experience drag.

6 days ago

Both are really good ideas. Signals will prob be really hard since some might go red late but would be very realistic if it overshoot or ignore them. (Thinking of logic gates/signals here, that block trains for players).
Curves yes please, very nice. I also just added a break sound mod. Maybe this is also an idea for you, since the mod seems not to react to the slow breaking (just on signals atm). This would give any slowdown like curves a feedback with sound then.
You also gave me another idea for you, elevation change should speed up or slow down a train ;)

I love this mod!

New response