Train Scaling

Automate the construction and deconstruction of your trains! Configure a train currently scheduled for a station as a template for the station - the mod's special train construction station will automatically build (or destroy) copies of the template train on demand, or in response to circuit conditions.
24 days ago
0.16 - 0.17
Owner: shanemadden
Source: shanemadden/factorio-train-scaling
License: MIT
Created: 8 months ago
Latest Version: 0.17.0 (24 days ago)
Factorio version: 0.16 - 0.17
Downloaded: 1239 times

Adds stations which automate the construction and deconstruction of trains for your factory on demand - set up a template train for a destination station, and each train built by the scaling station will be an exact copy.

Once the train scaling tech is researched, create a scaling station anywhere on the map to enable your train network to scale. You'll now see a new option for all of your train stations - enable scaling with the checkbox, then select one of the existing trains that's scheduled to go to the station as your "template" (stations with the same name share the same scaling configuration).

Drag the slider up to request additional copies of your template. Scaling stations with the necessary items available in their adjacent input chest will begin automated construction of a copy of the template.

Dragging the slider down to below the current level of copies will cause trains to be decommissioned - copies of the template train with nothing in their cargo will be selected to be sent to a scaling station for deconstruction. A train scaling station will attempt to deconstruct any empty, unoccupied train that parks at it - all of the train's parts are put into the adjacent output chest (an active provider chest ghost is placed in this position by default).

Circuit signals can also be used to trigger train scaling actions on stations which are enabled for scaling, in response to conditions like full mine chests, empty or full railyard "stackers", etc.

Because the effects of adding a train to the network can take a bit of time to be realized (and over-correction might cause a nasty traffic jam), the values on the signals act as rate limiters - sending 90 as the value on a "scale up" signal instructs the station to only request a new train if it hasn't already successfully started construction on one in the last 90 seconds. A configuration like this will request a new train if the chests are full of over 100k total plates, at most every two minutes:

Note that the circuit signals are checked at a relatively conservative rate (15 stations are checked every 5 seconds) to keep the performance impact negligible in large factories, so they'll need to be sent to the station for at least a few seconds to have any result - "pulse" signals which are only present for one tick are unlikely to trigger scaling.

Should support most modded trains, and equipment grids on the trains are fully supported.

Tested with:

Known issues with:

If you're using Logistic Train Network, you probably want to start all trains with a schedule to just go to a depot; leaving your template train out of the network in manual mode with a depot-only schedule will keep new copies going to the right place.

Translations and other contributions are welcome, preferably through GitHub.