Fix internal update of train max_speed

Things that already exist in the current mod API
Post Reply
d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Fix internal update of train max_speed

Post by d3x0r »

I'm not sure where the error is...
(speeds are given in internal m-per-tick)

In my train speed limter mod, I increase (uncap) the max train speed and modify the physics to make effective maxes that resemble the original.. but I've been trying to get trains to behave more correctly; Since I can't get their acceleration/cruising/decelerating state, I don't know when I can apply track modifier to speed...

in my mod I define a 'Q' for quality which is a multiplier applied train speed, and a rail max-speed setting, because some trains were able to overpower the low Q and go pretty fast anyway.

(applying track Q setting continuously)
if I have poor quality tracks that have a constant penalty (Q<1) to train speed, then when trains slow down approaching stops they slow to a crawl... Also if I have just a patch of poor quality track, that slows the train down a lot, and within the deceleration curve of the train before a stop, the train will not re-accelerate back to normal speed on better quality tracks (superior quality tracks will re-boost the train speed if I always apply the speed)

So I tried 'if train is accelerating (current train speed > the prior train speed )' then on high speed rails, trains cap out at the original max speed they were set with (in original mod's data.lua) and not the modified speed (in my data-update.lua). That is I will set a certain speed and they will drop back to their internal max speed of 1.2(hybrid-train original max-speed in data.lua) or 1.5(nuclear-train original max-speed in data.lua) which will make me stop applying the track modifier since they're not accelerating. The max_speed of the train is actually raised (4.0 in my data-update.luq), that is I can push the train this max when continuously applying a Q > 1 that is also greater than their air_resistance. If I don't override the max-speed than their speed is hard limited to their max_speed. I don't really understand why their original max_speed would even be an effect.

I have been playing with just single engines running around on tracks, and have not attached other carraiges which late yesterday I noticed have their own max_speed settings.

From game.enitty_prototypes I'm not able to get any information about speeds; so all of this is based on observations.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Fix internal update of train max_speed

Post by bobingabout »

I find it funny that wagon max speeds are higher than engine max speeds.

Also an issue with max speeds, the exoskeleton equipment when used on the train increases acceleration, but does not affect max speed. if you add grids to a train and fill them with this equipment, you'll find that your train pretty much instantly reaches it's max speed when it starts moving.
Seems counter intuitive when you note that to a player character, it increases the run speed, so in theory it's backwards. Works great on a tank though(They don't have a max speed, they already function the way you're trying to make your trains work).
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Fix internal update of train max_speed

Post by Rseding91 »

I don't understand what you're asking for. The max speed of a train is calculated based off the values in the prototype of each wagon in the train accounting for the fuel the train is burning.
If you want to get ahold of me I'm almost always on Discord.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Fix internal update of train max_speed

Post by d3x0r »

Rseding91 wrote:I don't understand what you're asking for. The max speed of a train is calculated based off the values in the prototype of each wagon in the train accounting for the fuel the train is burning.
Hybrid train burns no fuel, and instead has energy injected into it from accumulators that are found near the tracks (the tracks are built with a special rail accumulator that it uses for an energy source) so there's no fuel.
The nuclear train uses fusion fuel which has no bonuses.
there are no wagons.

https://github.com/d3x0r/train-speed-limiter#with-mod-2 Table of hybrid train speeds (running on .energy ) max speeds measured on various track types based on continous multiplication of 1.003 at every time (if I multiply much more than that I had problems with trains being able to stop)
The train max_speed was set to 4.0 (865kph) .
The limiting factor in these speeds is the train weight, engine power and air_resistance (and track speed multiplier)

the green line across happens when I only apply acceleration when the train accelerates ( current speed greater than prior speed) At the termination point, the point is eactly 1.2 (262kph), which is exactly what the original max_speed of the locomotive was set to.
accelcurves.png
accelcurves.png (14.93 KiB) Viewed 3138 times
Similarly the nuclear thain its original max speed is 1.5 and it truncates to exactly 1.5 (not some approximate value based on power and air resistance and fuel)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Fix internal update of train max_speed

Post by Rseding91 »

I still don't see an actual request.

What do you actually want?
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Fix internal update of train max_speed

Post by bobingabout »

how are you setting the max speeds?

in all cases.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Fix internal update of train max_speed

Post by d3x0r »

bobingabout wrote:how are you setting the max speeds?

in all cases.
with data-update.lua like I said to start?
and not the modified speed (in my data-update.lua)

hybrid train https://github.com/d3x0r/train-speed-li ... es.lua#L54
nuclear train https://github.com/d3x0r/train-speed-li ... es.lua#L70

standard train https://github.com/d3x0r/train-speed-li ... es.lua#L41 (wasn't testing with this at this time)

---
Maybe I have to visually demonstrate the issue... and a picture and/or words is failing to convey it.
Will work on that after sleep (aka tomorrow which is really already today)

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Fix internal update of train max_speed

Post by d3x0r »

Rseding91 wrote:I still don't see an actual request.

What do you actually want?
Fix train max speed to be what I set and not what it was when the train was created?
Add riding_state support so I can test if accelerating and apply the bonus at all times it is accelerating and not try to guess based on delta speed?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Fix internal update of train max_speed

Post by Rseding91 »

d3x0r wrote:
Rseding91 wrote:I still don't see an actual request.

What do you actually want?
Fix train max speed to be what I set and not what it was when the train was created?
Add riding_state support so I can test if accelerating and apply the bonus at all times it is accelerating and not try to guess based on delta speed?
Max speed of a train is calcualted as: min(all wagons in the train max speed)

You have to make sure you set max speed on every locomotive, cargo wagon, and fluid wagon if you want a train composed of them to use that max speed.
If you want to get ahold of me I'm almost always on Discord.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Fix internal update of train max_speed

Post by d3x0r »

Okay; turned out to actually be somewhat coincidental and limits that I ended up reverting to test that I was fighting.
also realized I was trying to fight pushing the train over what it could do with air resistance etc *1.003" instead of making the max multiplier less than 1 and always being a penalty to what it could otherwise do.

Post Reply

Return to “Already exists”