Page 1 of 1

[MOD 0.13.x] Dynamic Train Stop

Posted: Mon Jul 11, 2016 1:12 pm
by Aladrius
Train station that renames itself using circuit network input.

https://mods.factorio.com/mods/Aladrius ... train-stop

To forestall the inevitable "just use smart trains" replies, yes, I know smart trains will do all this and more. I wanted a lighter weight alternative that leverages the existing train route logic and lends itself to more in-game creative solutions.

Lamp coloring uses any "color" signal of 1 or more, and preferences them in order of appearance in the signals menu.

Research "Dynamic Train Stops", requires Automated Rail & Circuit Network

To use the renaming function, two things are required:

1> Build a Dynamic Train Stop called "DynamicControl" This can be anywhere on the map -- don't use it for a route destination. I suggest a lonely 1-chunk length of rail connected to nothing for it. Only one Controller station is required for any number of Dynamic Stops.

2> Name your station With a | (pipe) character in it. Anything before the | is preserved, after will be written by the train station logic. Stations with no color signal will drop the portion after the |. For example: a station named Iron| with a signal of 1 Red will be updated to Iron|Red, 1 Green to Iron|Green. As with the lamps, Red wins over Green if both are present.

Notes:
The DynamicControl stop is destroyed/replaced each time another station changes name. You might hear the placement 'whump' if you're in the area.
Station names are updated every 30 ticks (1/2 second) while the circuit network is updated each tick. If you have a train departing a station on the same signal that set its next stop name, it will depart slightly prior to its next stop being valid, and ignore the stop. Incorporate a small delay to work around this.

A couple quick examples of how I'm using it:

1> Outposts. Along my border walls, roboports are supplied with a mix of items by a dedicated supply train, basically directly following the Friday Facts setup:

https://www.factorio.com/blog/post/fff-140

Instead of having the train mindlessly loop each outpost in sequence, I name them all Outpost|
If the quantity on hand of any item drops below 1/2 of the desired quantity, combinators send 1 Red to the station, name becomes Outpost|Red
Supply train has two stops in its route, "Resupply" where it gets stocked with goodies, and "Outpost|Red". It will sit at "Resupply" until an "Outpost|" station changes its name, at which point it will depart for the "Outpost|Red" station.

2> Multiple mines supplying a smelter. Train has a schedule of "IronSmelt" and "Iron|Green". Station uses # of ore on hand, and sets Green = 1 when Iron Ore > 1500. Train only departs the smelter station when there is a good chunk of ore to pick up.

Thanks to Schorty's Pollution Detector and Choumiko's Smart Trains mods, both were invaluable for figuring out how to make things work.

Re: [MOD 0.13.x] Dynamic Train Stop

Posted: Mon Jul 11, 2016 6:54 pm
by Lethys
Sounds like a great mod, already thought of lots of ways to use it. :)

One thing though; the "DynamicController" actually has to be called "DynamicControl". I was wondering why it wasn't working for me and checked the code for the fix. Please update it here and on the mods website!

Re: [MOD 0.13.x] Dynamic Train Stop

Posted: Mon Jul 11, 2016 8:47 pm
by Aladrius
Lethys wrote:Sounds like a great mod, already thought of lots of ways to use it. :)

One thing though; the "DynamicController" actually has to be called "DynamicControl". I was wondering why it wasn't working for me and checked the code for the fix. Please update it here and on the mods website!
Updating that now, good catch!