Making fluid wagons work on a curved rail

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Making fluid wagons work on a curved rail

Post by blazespinnaker »

Hi folks,

I see from the bug reports that fluid wagons and pumps aren't supported when part of the train sequences (not the fluid wagon themselves, of course) are on a curved rail. I've had hit or miss success with this and it worked the first time but not the second time. When using long trains not being able to used curves at stops is a bit of show stopper.

Is there something we can do to, perhaps with the debug options, to figure out how to align the rail so that it works?

Cheers
OptimaUPS Mod, pm for info.
posila
Factorio Staff
Factorio Staff
Posts: 5360
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by posila »

You can make a mod that disables this by increasing fluid_wagon_connector_alignment_tolerance on pump entity prototype.
blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by blazespinnaker »

That would require more effort than simply re-arranging the rails. Is it possible to simply change a file or execute a lua command?
OptimaUPS Mod, pm for info.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by ptx0 »

blazespinnaker wrote: Mon Sep 27, 2021 2:37 pm That would require more effort than simply re-arranging the rails. Is it possible to simply change a file or execute a lua command?
you would have to change one of the core prototype definition files, which is arguably more work than using a mod.

in fact, there's already a mod for this: https://mods.factorio.com/mod/fluid-wagon-curved-rails
mrvn
Smart Inserter
Smart Inserter
Posts: 5881
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by mrvn »

ptx0 wrote: Mon Sep 27, 2021 3:25 pm
blazespinnaker wrote: Mon Sep 27, 2021 2:37 pm That would require more effort than simply re-arranging the rails. Is it possible to simply change a file or execute a lua command?
you would have to change one of the core prototype definition files, which is arguably more work than using a mod.

in fact, there's already a mod for this: https://mods.factorio.com/mod/fluid-wagon-curved-rails
I see that sets the tolerance for pumps to connect to 1.0. Is that pixels? Tiles?

I assume the aim is to make it tolerant to the fluid wagon being slightly off after a curve. But what happens after 2 curves? or 10? A train with 1000 fluid wagons and 100 locomotives can go around a lot of curves. If it's tolerant up to 1 tile then I guess at some point you just move the pump by 1 tile to compensate.

I really wish they would change the curve radius just a little bit so the wagons would align after a curve.
blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by blazespinnaker »

Yeah, I saw that, but it's not listed in Factorio mods for installing.

If I just have to edit a text file, that sounds pretty trivial. However, if it is some sort of binary edit, than yes a mod would be easier though likely not easier than just moving all the fluids to a vertical rail.
OptimaUPS Mod, pm for info.
blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by blazespinnaker »

ok, so 10 second change in C:\Program Files\Factorio\data\base\prototypes\entity\entities.lua

fluid_wagon_connector_alignment_tolerance = 1.0, (was some fraction before)

And seriously, in alt mode you can't even see the graphic! I mean, geez guys

can't believe I wasted silly amounts of time on this.
OptimaUPS Mod, pm for info.
foamy
Filter Inserter
Filter Inserter
Posts: 432
Joined: Mon Aug 26, 2019 4:14 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by foamy »

mrvn wrote: Mon Sep 27, 2021 3:50 pm I really wish they would change the curve radius just a little bit so the wagons would align after a curve.
You can't do it without giving up circularity on the curve or the rail grid. Pi is your enemy. Wider tolerances on the pump connection's basically the only option that doesn't break things.
mrvn
Smart Inserter
Smart Inserter
Posts: 5881
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by mrvn »

foamy wrote: Mon Sep 27, 2021 7:03 pm
mrvn wrote: Mon Sep 27, 2021 3:50 pm I really wish they would change the curve radius just a little bit so the wagons would align after a curve.
You can't do it without giving up circularity on the curve or the rail grid. Pi is your enemy. Wider tolerances on the pump connection's basically the only option that doesn't break things.
Nothing to do with circularity. l = 2 * Pi * r. If you want l to be an integer then r just becomes a irrational number. The change in r should be rather small and you wouldn't have to change the graphics at all. Just allow some tolerance in the connections between train cars so everything draws exactly like now while the radius being slightly different.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3041
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by boskid »

I was already thinking about changing the curved rail length from 7.842 to exactly 8 (so the position function would be tighter a little bit) so the distances on curved rail were not kept properly, but this approach turned out to be a garbage anyway because a 90deg bend will also contain an odd number of diagonal straight rails which are 1.414 long. I am not going to change them to be 2 tiles long as that would be too much distortion. Only other possibility would be to have diagonals 1.5 long but then the curved rails would have to be 7.75 long. This approach with diagonals of 1.5 would only work with 90 deg bends where there are odd numbers of diagonals. In case of a rail shift by 6+2N tiles there are odd numbers of diagonals and the train would be misaligned by exactly 0.5.

The only proper solution would be to rework the pump entity itself so it does not have this arm to reach a fluid wagon fluid connector or to change it in a spider-leg-like way where it would work with any possible fluid connector position. With that solution it would be allowed to work with any train alignment.
foamy
Filter Inserter
Filter Inserter
Posts: 432
Joined: Mon Aug 26, 2019 4:14 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by foamy »

mrvn wrote: Tue Sep 28, 2021 3:40 pm
foamy wrote: Mon Sep 27, 2021 7:03 pm
mrvn wrote: Mon Sep 27, 2021 3:50 pm I really wish they would change the curve radius just a little bit so the wagons would align after a curve.
You can't do it without giving up circularity on the curve or the rail grid. Pi is your enemy. Wider tolerances on the pump connection's basically the only option that doesn't break things.
Nothing to do with circularity. l = 2 * Pi * r. If you want l to be an integer then r just becomes a irrational number. The change in r should be rather small and you wouldn't have to change the graphics at all. Just allow some tolerance in the connections between train cars so everything draws exactly like now while the radius being slightly different.

If you make r an irrational number, you lose the grid. If you make both r and l integers, you lose circularity.
quale
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Thu Aug 15, 2019 4:16 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by quale »

Not that rail circles are all that circular in Factorio. There are straight diagonal pieces in there. A curved piece cannot mathematically have constant curvature and have the endpoints that it has. It’s easy to see with the naked eye. Nevertheless, the length does appear to be irrational.

It also isn’t an absolute showstopper. With the right combination of curved and diagonal pieces, you can get a length close to an integer, within unmodded tolerances. The amount of rail and wagons to realign is still a mild disaster, however.
mrvn
Smart Inserter
Smart Inserter
Posts: 5881
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by mrvn »

boskid wrote: Tue Sep 28, 2021 3:52 pm I was already thinking about changing the curved rail length from 7.842 to exactly 8 (so the position function would be tighter a little bit) so the distances on curved rail were not kept properly, but this approach turned out to be a garbage anyway because a 90deg bend will also contain an odd number of diagonal straight rails which are 1.414 long. I am not going to change them to be 2 tiles long as that would be too much distortion. Only other possibility would be to have diagonals 1.5 long but then the curved rails would have to be 7.75 long. This approach with diagonals of 1.5 would only work with 90 deg bends where there are odd numbers of diagonals. In case of a rail shift by 6+2N tiles there are odd numbers of diagonals and the train would be misaligned by exactly 0.5.

The only proper solution would be to rework the pump entity itself so it does not have this arm to reach a fluid wagon fluid connector or to change it in a spider-leg-like way where it would work with any possible fluid connector position. With that solution it would be allowed to work with any train alignment.
Curved stations are usually using 180° turn. At least I have never seen a station with an S curve. The 7.75 for curved and 1.5 for diagonals sounds fair to me. That would work for 90°, 180°, 270°, 360° turns as is.

As for stations with an S curve: 2 curved rails + 2 diagonals = 2*7.75 + 2*1.5 = 15.5 + 3 = 18.5. So, as you say, 0.5 out of alignment. Why can't pumps deal with that?

Normally the pump can be in one of 4 tiles (2 per side) to connect to the tank in the center. So it reaches 0.5 tiles across. With a 0.5 tile offset a pump that reaches straight would fit perfectly. It would require new graphics for a straight reaching arm. Would that be so much work or just setting a new angle in the 3D model and rendering it again? I guess you also need to extend the prototype for the third arm position. Still doesn't sound earth shattering.
foamy
Filter Inserter
Filter Inserter
Posts: 432
Joined: Mon Aug 26, 2019 4:14 am
Contact:

Re: Making fluid wagons work on a curved rail

Post by foamy »

quale wrote: Tue Sep 28, 2021 7:59 pm Not that rail circles are all that circular in Factorio. There are straight diagonal pieces in there.
That's true, but it's still got two smaller 22.5 degree curves at the beginning and end of the rail, which causes the same issue. And, even in the case where there was a strict 45 degree diagonal with an unsmoothed join, that would still give you irrational lengths because the square root of 2 is also an irrational number.

So you can't win. I suppose you could try and fudge things by jiggering exactly where the curves and straight alignments are, but I think it'd get real messy real quick.
quale
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Thu Aug 15, 2019 4:16 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by quale »

foamy wrote: Tue Sep 28, 2021 10:24 pm So you can't win. I suppose you could try and fudge things by jiggering exactly where the curves and straight alignments are, but I think it'd get real messy real quick.
It isn’t entirely unreasonable. For mrvn’s 180° turn, you can add two extra diagonals (4 curves and 4 diagonals in total). That’s still within tolerances when you do it twice. But that’s the best of the worst. The most compact solution for a 90° turn is 2 curves with 25 diagonals. There’s your mild disaster. At least the next turn can consist of as little as 2 curves with 3 diagonals.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Making fluid wagons work on a curved rail

Post by ptx0 »

it's times like this that i wish my brain worked better with geometric maths. where's my TI-89 calculator...
Post Reply

Return to “Gameplay Help”