Hello World for LTN - A Beginner's Guide

Adds new train stops forming a highly configurable logistic network.

Moderator: Optera

Kyralessa
Filter Inserter
Filter Inserter
Posts: 687
Joined: Thu Sep 29, 2016 5:58 pm
Contact:

Hello World for LTN - A Beginner's Guide

Post by Kyralessa »

Hello World for LTN - A Beginner's Guide
In looking through LTN guides trying to figure out how the heck it works, I haven't found one that starts with the most basic setup. I don't want to start with 50 trains, or a perfectly balanced set of loading chests; I just want to get a Depot/Provider/Requester loop running.

Since that simple guide doesn't seem to exist, I've written it, and I hope it helps you get started. (If you find any mistakes, please let me know and I'll edit to fix it.)
Mods
First, enable these two mods:
  • LTN - Logistic Train Network
  • LTN Combinator Modernized
(Technically you can do everything with regular constant combinators, but LTN Combinator Modernized will make your life much easier.)
Sandbox mode
In this mode you can instantly create the items you need.

From the opening screen, choose Single Player → New Game → Sandbox.

Enable all the startup choices:
  • All Tech, please
  • Items, please [optional]
  • Cheat mode, please
  • Always day, please
Layout
We're going to make a very simple layout with 1 depot, 1 requester, and 1 provider. We'll use green wires to connect things. (Red works fine too; just make sure you use the same wire color throughout, for consistency.)

First, make a rail loop large enough to comfortably fit three stops around it.

Around the loop, place 3 Logistic Train Stops, roughly equidistant. Make sure they're all facing the same way. Name one of them Depot, one Provider, and one Requester.
Loop

You'll also need to set up a few solar panels to power your inserters.

Now let's configure the stops and the train.
Depot stop
  • Place an LTN Combinator near the Input (Lamp) and connect them with a green wire.
  • Set the LTN Combinator to Depot mode.
Depot
Train
  • Put a train on the tracks with one locomotive and one cargo wagon. (Make sure it faces the same way as the stops.)
  • Set the train's destination to the Depot, and add a 5-second inactivity condition.
The train will proceed to the Depot and stop. The Depot's light, which was green, will turn blue, indicating that the train is ready for instructions.

You don't need to set any other schedule on the train. LTN will take care of that for you.
Train at depot
Requester stop
  • Place an LTN Combinator near the Input (Lamp) and connect them with a green wire.
  • Set the LTN Combinator to Requester mode.
  • Place 6 steel chests alongside where the wagon will go, with inserters on each side, to unload the wagon and then the chests.
  • Green-wire all the chests (and power poles where needed) to the LTN combinator.
  • Set the Request Stack Threshold in the LTN Combinator to 40 (one wagon load). When you do this, you'll get a warning that there's no provider. We'll fix that later.
  • In the LTN Combinator's Output signals section, click an empty space, and select rocket fuel. (This has a stack size of 10, which is handy so we don't have to wait all day for the wagon to load or unload.) Set the Stacks to 40. The combinator will automatically adjust this to an output signal of -400 rocket fuel. This is negative because it indicates the deficit of items at the requester stop.
(In "real life" with 6 chests and rocket fuel we'd set the output signal to -2400, or with 12 chests, -4800. We're limiting it for demo purposes.)
Requester
Provider stop
  • Once again, place an LTN Combinator near the Input (Lamp) and connect them with a green wire.
  • Set the LTN Combinator to Provider mode.
  • Place 6 steel chests alongside where the wagon will go, with inserters on each side, this time to load the chests and then the wagon.
  • Green-wire all the chests (and power poles where needed) to the LTN Combinator.
  • Set the Provider Stack Threshold in the LTN Combinator to 40 (one wagon load). (This means this stop won't appear as a provider until there's a full wagon load to pick up.)
Provider
Restocking
Now that the stops are otherwise set up, make a belt connection from the Requester to the Provider. After we deliver to the Requester, the rocket fuels will get "used up" by flowing back to the Provider to be restocked for another delivery. This lets us see LTN in action with a continuous Provider/Requester loop.
Now watch it go!
If everything is set up properly, then you should see this happen:
  • You'll get a notification about a delivery being scheduled.
  • Your train will head for the Provider and load up.
  • When your train goes 2 seconds without any loading activity, it'll head for the Requester.
  • At the Requester, your train will unload.
  • When finished unloading, your train heads to the Depot to wait for another delivery.
  • The rocket fuels are moved back to the Provider to start another cycle.
In action
OK, it works, but why? How?
In principle, LTN is based on train loads. A Requester requests when there's room for a full load to be delivered. A Provider only provides when there's enough material for a full load to be taken away. (You can decide how much a full train load is.)

The Provider only needs one setting: When is a full train load available? We can set this by items or stacks. Our setting of 40 stacks means that when 40 stacks or more of any (non-fluid) item are available, LTN is allowed to schedule a pickup if there's a corresponding request for that item. If fewer than 40 stacks are available, nothing will be picked up.

The Requester needs three settings:
  • What item do we want?
  • How much can we currently accept? (How much room do we have for it?)
  • At what deficit point should we actually deliver it?
The first two of these are both covered by our output signal of -400 rocket fuel. This indicates that (a) we want rocket fuel, and (b) we have space for 400 of them (a full train load).

Suppose we deliver 300 rocket fuel (and it doesn't get moved away immediately). That 300 rocket fuel combines with our -400 to yield a signal of -100 rocket fuel, indicating we have room for 100 more (10 stacks).

The Request Stack Threshold indicates when we should make a delivery. Remember, our Request Stack Threshold is set to 40 stacks. -100 means we only have 10 stacks free. So we won't get a delivery. If we change the Request Stack Threshold to, say, 10 stacks, then -100 (10 stacks available) is sufficient to trigger a delivery.

We could also clear the Request Stack Threshold and set the Request Threshold to 1. This means that as soon as a single rocket fuel is removed from the full chest, a delivery will be scheduled.

What if we set the Request Stack Threshold higher than the output signal's maximum (negative) amount?

Then we'll never get a delivery. This is because we'll never show a deficit as high as the Request Stack Threshold. Working with the same -400 rocket fuel baseline, suppose we set the Request Stack Threshold to 1000. Now a delivery will only be scheduled if we have a signal of -1000 rocket fuel, but this will never happen; the -400 that we've set is our limit.
In conclusion (TL;DR)
  • Send a train to the Depot with an inactivity timer and no other schedule.
  • Set the Provider Stack Threshold ("How many stacks is a full load?") and wire up its chests so it knows how many items it has.
  • Set the Requester Stack Threshold ("How many stacks is a full load?") and wire up its chests so it knows how many items it has.
  • Set the Requester output signal to show what item it wants, and the maximum it can accept (if all its chests are empty).
Have fun!
Now that you have a basic setup, you can experiment with adding more depots and trains, more item types, reconfiguring, etc. Save your game first so you have a baseline to return to if something gets snarled up.

Enjoy your new train logistics network!
Post Reply

Return to “Logistic Train Network”