LTN - Logistic Train Network

by Optera

Adds logistic-train-stops acting as anchor points for building a fully automated, train logistic network. It can handle all possible train configuration. Just send all trains to depots and LTN will pick the best suitable train for a job. LTN cuts the amount of rolling stock required to run a megabase down to 30% or less. With cargo ships installed also adds a logistic port for ships.

Content
a day ago
0.14 - 2.0
271K
Trains Circuit network

b Fuel station resets schedule

5 months ago
(updated 5 months ago)

I've had some wonky train deliveries this game, and I just caught one of the trains at it. It seems to be caused by the fueling station which is acting like a depot and assigning a new schedule to my trains. Here is the order of events:
Train goes to fill up on coal (this is where I depleted its fuel to trigger refueling)
Full of coal, train heads to the temporary stop at coal unloading
At the temp stop (before unloading) the refueling interrupt triggers and the train diverts to my fuel station
On arrival at the fuel station the schedule clears and the train refuels. The refuel station is assigned to the schedule as if it were a depot, and the train (still full of coal) is assigned a new schedule.

My refuel station is only that, the signals on its combinator are 1. stop is fuel station, 2. encoded network ID, 3. limit trains, and 4. solid fuel 20.
Am I missing something?

4 months ago

can you share a screen shot or a save? The fuel station should only show as a temporary stop and the train should be sent back to the depot after refueling.

Do you have other mods loaded?

4 months ago
(updated 4 months ago)

While I was recreating a simple save for this, I identified part of the problem.

Here's a mockup. To recreate:
1 - Start the train. It will go load up on coal.
2 - While it is loading coal, remove two stacks of fuel from the locomotive
3 - The train will try to refuel before unloading, and reset its depot to the refueling station name

https://drive.google.com/file/d/1cmzRaHQeymbY22zOOlt1aL3ol2CJnLev/view?usp=sharing

Now, here's how we got here -
For my refuel depot, I pasted in one of my standard LTN depot blueprints (you can see three of them in the save). Then I went to its combinator and deleted the depot signal, and added in the refuel signal to make it a refueling station. Somehow, the refueling LTN station still has a little bit of an idea that it is a depot too. If I delete the LTN station and rebuild it, connecting it back to the same combinator, everything works fine.

4 months ago

will take a look. Thanks for sharing a save

3 months ago

Just wanted to say thanks for the solution, Spacey42. As you said, I just had to rebuild the station and the trains started to leave the fuel station instead of staying there.

2 months ago

So I could reproduce this (arrive at temp stop, then send to refuel, then reset the schedule).

It is a bug, I have a fix; the good news is that it is easily fixable.

Here is an assumption: This refueler, at some point in its past, was a depot and then repurposed as a refueler.

When the state of the station changes (depot -> refueler), it added "this is a refueler" to the internal status but did not reset the "this is a depot" bit. So when the train arrives, the "I am a depot" bit actually wins and so the schedule is reset and the train is "stuck" in the "depot".

This will be fixed in the next release. There will actually be two fixes:

  • there will be no refueling scheduled if the current stop is a temporary stop without a station
  • if a station changes from depot to fuel station, it will be correctly updated

Thank you for the bug report and the reproducer; It took me a while to get back to LTN. I plan to release this weekend or early next week.

a month ago

This is fixed in 2.4.x

a month ago

Thank you!

a month ago
(updated a month ago)

hi, I found this topic because I've experienced the same problem. I checked, my LTN version is 2.4.2, which should have the fix.

In my case the result is the same as Spacey reported, my trains get stuck at the refuel station, with their original train schedule gone, which was only "go to depot".

however my case is weird... I forgot to actually enable the option in the settings for probably the last 20h.

After finally noticing it and turning on the setting the trains actually are sent to the refuel station and get stuck the same as mentioned above. However... my refuel station is no longer wired to the constant combinator giving the "refuel station" signal, I probably disconnected that by accident in the beginning.
I didn't notice that my refuel station wasn't working for so long because I use nuclear trains, their initial fuel lasts for a long time.

After that I tried removing the station and combinator, placing it again and hooked up the wire and it turned light blue (it was green lamp before). I noticed that the trains get a new refuel interrupt added to their schedule after entering a depot. However its never triggering, even when I manually remove all fuel.
I tested this by removing fuel while they were waiting in depot, and removing fuel on a train in the process of making a delivery. They dont go refueling anymore.
I can manually click on the refuel interrupt and it works fine.

So in short:
- Forgot to enable refuel station, but placed a refuel station, but accidentally disconnected the wire after some time, all while the setting was disabled.
- Enabled refuel station setting. Trains get send to the station despite not being hooked up to the combinator. Get stuck the same way as described above (no interrupts created in their schedule).
- Creating a new refuel station now adds interrupts to the trains, the station now has a light blue lamp, but the trains now never visit the refuel station.

Edit: Did some more testing, trains refuse to go to the refuel station. out of the 30 trains 10 got their fuel removed. Not a single one ever went for fuel and 5 of them ran out of fuel and stopped.
Removed the fuel from a further 10. I reset their schedule completely and readded the Depot station. 3 of them ran out of fuel after a while, however a single one of them did go refuel at some point. (cant keep my eyes on 20 trains zipping around the base at once...). I don't know why one did it correctly and the rest is still refusing. It is one of those that got their schedule reset, easy to identify because the "old" ones still got a wait timer of 5s and the new ones got 2s automatically added (i changed that in the settings some while ago).

Edit2: I cant recreate the one train that actually refueled. Here is a savegame.
https://drive.google.com/file/d/11-8Ehd5mRE4O3X_5S9JiSZfCKDSBbYLu/
This save is after I enabled the refuel station setting but not yet wired or replaced the refuel station.
The refuel station is called "(UranFuelCell_Icon) LTN Refuel". If you load the savegame one train is already on its way to that station and arrives within 15seconds, having lost its schedule already and driving to the not-wired LTN Refuel Station. If you wire the station to its constant combinator you can observe how the trains get their interrupt added upon arriving in a depot. but they never go refuel.

My modlist has a mod in the top left that allows you to speed up or slow down time.

Edit3: found hidden in the github page that refuel stations need a fuel-item in its signal. Adding the uran fuel cell signal now actually sends most trains trains to visit the station to refuel properly now. Some still refuse and will run out of fuel...
Also this doesn't explain why trains randomly decide to go refuel despite the station not being set up properly (no fuel signal), or why the train try to reach a a LTN Refuel station thats not even hooked up to a constant combinator. and why their schedule gets wiped.

a month ago

Thanks for the report. having a game save is good. I will not get to this before the weekend but I will take a look then.

17 days ago
(updated 17 days ago)

dozens of hours later I've got LTN behaving like it should. I did some tests while I still had problems and here are some steps I could reproduce, although its somewhat random when the bug happens and its hard to reproduce due to timing (train needs enough fuel to make delivery but not enough after it, etc):

steps:
Build stations, build a refuel station (without fuel in its signals, but signal connected), build some trains.
The trains wont refuel ever, they run out of fuel.

this is expected, no fuel type defined.

Disconnect the signal wire to the refuel station. The trains now enter the station sometimes instead of running out of fuel and their schedule gets wiped.

bug

Any train built while the station is disconnected => those trains also get their schedule wiped.

still same bug

Lets call these two train groups "pre-disconnect" and "after-disconnect"

Setting up the correct fuel type signal and reconnecting the stations wire.
the "pre-disconnect" group now behaves and refuels correctly without schedule wipe.

solved

"after-disconnect" group still runs out of fuel but doesnt get their schedule wiped anymore since they now do not try to enter the refuel station.

bug

deconstructing trains and rebuilding them seems to lower and aaaaalmost eliminate the problem, but sometimes they still run out of fuel.
I got new locomotives (mod of course) and before deploying them I removed every single train first, then build the new one. After this everything behaved correctly for whats now probably another 24h of playtime.

My best guess is: the refuel station that I never gave a fuel type somehow remains in the memory of LTN, messing with trains after its been disconnected, and that buggy behavior remains until all trains are wiped completely. Trains either enter the disconnected station when they shouldn't and get their schedule wiped, or ignore that a (reconnected) refuel station exists and run out of fuel.

4 days ago

You said "trains enter the station sometimes". What signals are you sending into the refuel station? Just the "refuel" signal but nothing else?

To refuel a train, two things must match:
- the train has some fuel.
- a refuel station exists that has the same type of fuel.

So if your train is burning wood, it will only move to a fuel station that offers wood. It will not select a station that offers e.g. rocket fuel.

That is because there is no real connection between the fuel offered ("200 wood") and the fuel that will be loaded onto the train (if any). One thing that I can do (and I might just do it and put it behind a config section) is to convert the offered fuel into MJ and do the same with the fuel on the train and compare those. In that case, any train will move to a fuel station if its energy falls below the signal from the station.

I am not clear how the train would ever call on a fuel station if it does not offer fuel. A fuel station will only ever added to the schedule when it offers fuel, and the fuel matches the fuel on the train). To figure that out, I would need a save.

4 days ago

I just pushed 2.4.3 which contains some logic that ensures when a fuel station or a depot get deselected ("lose their signal"), they will be explicitly marked as "no longer a fuel station / depot". This should solve the problem of "trains go to the fuel station sometimes, even if there is no signal".

Finally, do you use interrupts for refueling or the "dynamic" refueling (controlled by a map setting)?

LMK if 2.4.3 works better for you. Refueling is still a work in progress.

3 days ago
(updated 3 days ago)

Ok, so I found some time to really dig into your save. There is a lot going on there (I do like the hexagonal design, something I have not considered before)

  • 2.4.3 definitely fixes the "trains are sent to refuel even if the station has no signals" problems. I did not have any train sent to the refueler until I reconnected and added a fuel signal (uranium-fuel-cell)
  • Your refuel station had a train limit set on the LTN stop. This is a problem as the train stop limit is interfering with LTN operations. I added code that explicitly resets train limits on stop entities. You can still use the ltn-max-trains signal for that purpose. Changing this in the LTN code is possible but would require some rewriting
  • Adding a fuel signal like 'uranium-fuel-cell = 1' is a problem with interrupts as the current checks would be "out of bounds : > 0 and < 1, which is not possible. I changed the upper bound check to be <="
  • when testing, do not remove all the fuel from a locomotive. If that happens, the interrupt will not trigger (this is a limitation of the Factorio Train Interrupt system). Basically, you need some fuel left for the interrupt to trigger. Same applies for "dynamic refueling" (where the code changes the schedule).
  • I added a visual signal when a refuel station has been designated (gets the refuel station signal) but no actual fuel signal. In that case, the lamp now turns grey, not cyan
  • I added a small fix to the code that it will not select a fuel station without fuel for refueling (because that would make no sense. ;-) )

I will release 2.5.0 sometime today or tomorrow; there is another fix that I want to look into before doing so.

New response