Intermediate Factorio Lab:

A Framework for Directing Trains by.

This lab objectively outlines a framework for sending a single, unspecified train to a specified train stop. Train stops are identified by some non-zero value on signal S; e.g. train stop 1 is represented by S = -1, train stop 2 by S = -2, train stop 3 is S = -3 and so forth. We will send some train, T, to the train stop of our choice by broadcasting a pulse of the signal representing the train stop S(N) we want T to visit to the global circuit network. Assuming T is stopped at a configured station and upon receipt of the pulsed signal, T will directly make it’s way to S(N). With T at S(N), any configured station will be available for use.

Motivation:

“But this can be done already by selecting stations and trains!”

Absolutely. The motivation behind developing a framework for moving a train by signal is really to provide an extensible interface to automate train logistics workflows. For instance, using this frame work, it’s possible to detect when construction materials are low, send a train to your HQ, collect the materials, and then transport those materials specifically back to the site of origin automatically. The goal of this framework is to provide an effective place to start with more advanced train automation outside the scope of manufacture. This framework was primarily created for construction [CX] networks and construction automation. Mileage may vary with use case.

Recommended mods:

Pushbutton by justarandomgeek (optional – but highly recommended!)

Significant considerations:

– The global network is connected by green wires. It’s our signal ‘backbone’. Train stops are ‘indirectly’ connected to the global network to provide more granular control of signals coming in.

– We will be working with pulsed signals although this works just fine by turning a constant combinator on and off. A rudimentary example of a pulse generator (an edge detector) will be provided for convenience. Additionally, feel free to check out justarandomgeek’s Pushbutton mod which introduces a pushbutton as well as F as a hotkey to flick the button and a constant combinator on and/or off. The pushbutton mod provides quality-of-life even if you’re not going to use the button as you can still flick combinators on or off using the F hotkey.

– Once the train, T, makes it way to the stop S(N), the train will have continued access to the other configured stations. That means the default state of train station is ON.

Major challenges:

– Fundamentally, we want to direct T to S(N) by enabling stop S(N) and providing T with a circuit condition to enable locomotion. If we provide a train stop with an ENABLE condition of S = N, that means, by default, that all the stations are disabled (S = 0 by default) , and even if we pulse S(N), once the pulse is over the train will not move and indicate NO PATH since S(N) will be disabled. This is overcome by using combinators to enable the station while S = 0 OR S = N. This works because S = X and S = 0 are an explicit conditions and there will be no edge cases were both S = 0 and S = X are simultaneously TRUE.

– Locomotion for T at S(N) is controlled via signals as well. If T is at S(N), then we only want T to move when S != N. T must be configured as such per station such that the wait condition at train stop T has a wait circuit condition S != N.

The Lab

Instructions:

1. Build the railway for the test lab. It is highly recommended that the railway is (a) a loop and (b) properly signaled.

2. Install train stops. Don’t wire them yet.

3. Run supporting infrastructure. You will need to:

(a) provide power and power distribution (power poles)

(b) implement a circuit network by connecting all the power poles together. This is the global (circuit) network. DO NOT directly wire the train stops to the global circuit network.

(c) *DO NOT directly wire the train stops to the global circuit network.*

4. Place 2 Deciders and one arithmetic down. In this lab, I will be consistently using negative virtual signals but you can use positive signals if you’d like. That means train Stop 1 is S(-1) so my equality and multiplication would be with NEGATIVE constants.

D1: S = 0 :=> S(1),

D2: S = N :=> S(1),

A1: S * N :=> S

For example, for S(-2) (station 2)

D1: S = 0 :=> S(1),

D2: S = -2 :=> S(1),

A1: S * -2 :=> S

If S = 0 OR S = -3 THEN SEND S = 1

S * -3 :=> S (S = -3 in this example.)

IF S != { 0, -3} THEN S = 0

wire (green) the inputs of D1, D2 to the global network. Wire outputs of D1, D2 (color of your choice) to A1. A1 output is wired to the train stop.

Don’t forget to configure an enable / disable condition!

4. For each stop, Turn on Enable / Disable Condition to S = N where N is the stop ID of your choice (I used -1, -2, -3, -4). S(3) has a condition S = -3.

5. Do steps 4-5 for each of your train stops / stations

6. Place down a train. I prefer 2L-4C trains. Configure the wait conditions on the locomotive such that for Train Stop N the wait condition is S != N. The locomotive in this example is configured like this (C/C is short hand for circuit condition!):

STATION 1

C/C S != -1

STATION 2

C/C S != -2

STATION 3

C/C S != -3

STATION 4

C/C S != -4

Remember, for Stop S(N) the wait condition is S != N.

That means if S(N = 1) :=> Wait Cond. is S != 1

or S (N = -1) :=> S != -1

Toggle the train from manual to automatic or r just send it to STATION 1 – this will turn on Automatic mode.

7. Somewhere on the global network, place down a pushbutton or a pulse generator. An edge detector will be used as these are compact and simple enough. One constant, one arithmetic, and one decider will be employed for this purpose. If you’re using the pushbutton, you can skip this step, otherwise:

C1: S = N

A1: Ea. * -1 :=> Ea.

D1: Ea. < 0 :=> Ea. (Use > [greater than] if you’re using positive signals!]

Wire C1 out to A1, D1 In. wire A1 out to D1 in. This introduces a 1 tick latency in between N and -N, allowing 1 tick of N to ‘pulse’ when C1 is turned on before N & -N cancel themselves out (N + -N = 0). When C1 is toggled off, 1 -N pulse is generated as well which is why D1 is necessary – to prevent that pulse from cancelling the other pulse. Alternatively, D1 can be avoided but does introduce a single unnecssary -N pulse.

8. Send T to any arbitrary station of choice. Send T to STATION 2 (S = -2) or STATION 3 (S = -3). Call T back to STATION 1 by Sending S = -1.

PROCEED TO Intermediate Factorio Labs 2: https://panconbutter.home.blog/intermediate-factorio-labs-2/