Now you can connect/disconnect trains through the magic of circuits!
This mod adds two new virtual signals, couple and uncouple. When a train stops at a station receiving either (or both!) of these signals, it will attempt to couple and/or uncouple the train accordingly. If a station is receiving both signals, it will attempt to couple first, then uncouple.
Coupling/uncoupling only occurs when a train arrives at a station - if a train is already at the station when you send the signal, nothing will happen.
Note that these signals are only read by stations, and only work for trains under automatic control that stop at a station.
Coupling
If greater than zero, attempts to connect the train to another train in front of it. If less than zero, attempts to connect behind (I guess it's theoretically possible you could get this to work, with very careful timing)
Uncoupling
If greater than zero, disconnects that many cars from the front of the train, and if less than zero disconnects that many from the rear of the train. If the uncouple value is greater (positive or negative) than the number of wagons in the train, nothing happens. For example, "uncouple 1" will disconnect the lead wagon, "uncouple -1" will disconnect the trailing wagon.
Example
The train will travel from A to C, where it will immediately uncouple the first wagon (counting from the station), as instructed by the signal of "uncouple 1". The two locomotives will then immediately travel back to A.
From A the locomotives will move to B, where they will connect to the train in front of them, as instructed by the signal "couple 1". The train (two locomotives plus cargo wagon) will then immediately travel back to A.
Known Issues
If a train is successfully coupled or uncoupled, it will immediately depart for the next station on its schedule. This is unfortunately unavoidable. Changing the composition of a train resets it to manual control, and if it is not advanced to the next station on its schedule it will either fail to path (trains can't find a path to the station they're already at) or it will attempt to visit the same station again (and possibly trigger another uncouple).
Version History
1.0.0 - 2017/05/25 - Initial release
Re: [0.15] Automatic Coupler
Posted: Thu May 25, 2017 11:20 am
by driver
Could you please take a screenshot and explain how this works?
I have no idea how circuits work in combination with coupling.
Re: [0.15] Automatic Coupler
Posted: Sat May 27, 2017 3:50 pm
by bNarFProfCrazy
driver wrote:Could you please take a screenshot and explain how this works?
I have no idea how circuits work in combination with coupling.
I also have quite the issue with this.
I spend literally hours on this.
The only theoretically working solution I could come up with, requires me to always use double headed trains.
EDIT: After some thoughts i guess it would be nice if you could add a "transfer signal" that does first decouple and then couple.
(I'm fine with it being a flag value (true/false) or a functional value)
I'm not 100% sure what would be the best way to implement the transfer:
Option 1) Transfer x wagons from front if positive or x wagons from rear if negative
Option 2) Transfer x wagons from front if positive or all except x from front if negative
I would prefer option 2, as option one will not work because there shouldn't be a train directly behind us if we stop at a station.
Re: [0.15] Automatic Coupler
Posted: Sun May 28, 2017 6:43 am
by GotLag
I've added a screenshot and explanation of a working demonstration track. That train will happily move back and forth, alternating between picking up and dropping off the wagon.
Re: [0.15] Automatic Coupler
Posted: Sun May 28, 2017 8:19 am
by driver
The first thing I tried is to simply set up the circuit settings in the train schedule, which could be comfortable, but don't seem to work. You can leave them empty.
All you need to know is that you need to connect a constant combinator with a wire to a trainstop to turn it in a stop for coupling or decoupling by choosing the symbol for coupling or decoupling and a positiv or negativ value for the number of waggons you want to decouple.
Usually only one option (positiv or negative value) works for decoupling, the wrong decision can make problems (the locomotives don't move on or you can get waggons that can't find a path, although they don't have a locomotive attached to them). I wouldn't recommand to use filters for waggons.
Apart from this, this mod seems to work properly and is more comfortable to use than the other train coupler mod from NiftyManiac made for version 0.14.
Re: [0.15] Automatic Coupler
Posted: Sun May 28, 2017 2:42 pm
by bNarFProfCrazy
I managed to build a single headed switcher train station.
Switcher-Ffront-Cargo
Switcher-FrontCargo.png (1.26 MiB) Viewed 13517 times
Switcher-Ffront-Cargo-Zoomed
Zoomed.png (1.13 MiB) Viewed 13517 times
1) Read whether there us a train there
2) Block if there is no train in 1
3) Read whether there is the switcher there
4) Block access to Pickup_Station if there is the switcher in 3 or there is no train in 5
5) Check whether there is something to be picked up.
Suggestions for improvements are very appreciated.
While this front cargo variant would work, I would like to see a version where I can append cargo at the back using a single headed train:
Requested-Desing
Requested-Design.png (1.36 MiB) Viewed 13517 times
Re: [0.15] Automatic Coupler
Posted: Mon May 29, 2017 10:09 am
by driver
Interesting but too difficult to understand for me .
I'm still searching for an easy way to block locomotives from entering a trainstop and coupling, if there are no waggons available, because in this case the train is stuck and stop forever.
This was different with the traincoupler mod from Nifty Maniac which don't require circuits. If no waggons are available for coupling, the locomotives simply continue to move.
There seem to be a train detection for trainstops (T), but you can't use it to open a closed signal if a train is waiting. (apparently you can only close an open signal if a train is detected).
Re: [0.15] Automatic Coupler
Posted: Wed May 31, 2017 1:28 am
by totalwar57
Is it at all possible to uncouple multiple section of a train at once?
For instance, I have a train with 16 cargo wagons that I use to refill from my main store. I'd like to be able to move it to a single stop and break it into sections with 2 wagons in each, and then have each wagon picked up one at a time by other engines. This doesn't seem to work though. I tried outputting multiple uncouple signals, both from a single constant combinator and individual ones, and it just wouldn't uncouple anything at that point.
I have a possible workaround, just moving the entire train back and forth one space at time, but you can imagine that this will make the whole thing much slower and waste a bunch of fuel, so if there's a better way to do this, I'm all for it.
Edit: just attempted the workaround. Apparently having to move the train back and forth like that bugged the whole thing and I got hit with a no path error on a train without any engines attached. Maybe that's a good thing though, since I had no idea how I was going to signal this thing to work.
Re: [0.15] Automatic Coupler
Posted: Wed May 31, 2017 6:15 am
by bNarFProfCrazy
totalwar57 wrote:Is it at all possible to uncouple multiple section of a train at once?
For instance, I have a train with 16 cargo wagons that I use to refill from my main store. I'd like to be able to move it to a single stop and break it into sections with 2 wagons in each, and then have each wagon picked up one at a time by other engines. This doesn't seem to work though. I tried outputting multiple uncouple signals, both from a single constant combinator and individual ones, and it just wouldn't uncouple anything at that point.
I have a possible workaround, just moving the entire train back and forth one space at time, but you can imagine that this will make the whole thing much slower and waste a bunch of fuel, so if there's a better way to do this, I'm all for it.
Edit: just attempted the workaround. Apparently having to move the train back and forth like that bugged the whole thing and I got hit with a no path error on a train without any engines attached. Maybe that's a good thing though, since I had no idea how I was going to signal this thing to work.
The solution to your problem is uncouple all cargo wagons at once, then couple your switcher train to that train and also set the uncouple signal so you dont take all cargo wagons.
Signals on drop station: Uncouple 2 (or how many trains you would like to drop)
Signals on each pickup station: Couple 1 and Uncouple -4 (or how many trains you would like to keep at that station.)
Makr sure to place a train signal betwwen each section of the train.
If you need an 3xample have a look at my screenshot above (frontloader)
Getting errors like No path on cargo waggons means that you have to flip/negate the uncouple signal.
Re: [0.15] Automatic Coupler
Posted: Wed May 31, 2017 9:43 pm
by GotLag
I'm going to make some significant changes to how this mod works, hopefully should be coming by the weekend. These will make it much more useful and flexible, but there are a few problems to overcome first.
Re: [0.15] Automatic Coupler
Posted: Sat Jun 03, 2017 4:14 am
by totalwar57
bNarFProfCrazy wrote:
Signals on each pickup station: Couple 1 and Uncouple -4 (or how many trains you would like to keep at that station.)
Thank you! I'd tried it with multiple uncouple commands at once, which didn't work, but I didn't realize you could have a couple and uncouple command at the same station. That makes everything so much easier.
Re: [0.15] Automatic Coupler
Posted: Tue Jun 13, 2017 1:14 am
by leoch
Well, I've succeeded in making a nice yard with a double-ended engine moving three sets of wagons between two supply and two demand stations. Details on request (mostly hocus pocus to enable and disable stations at the right time, rather than program the whole rotation in the train schedule). Advantage: 1/3 the engines, smaller stations, and refuelling only needed at one stop.
It wasn't until I saw another post here that I realised you can use rail signals (if placed at the back of a wagon, the previous signal will go green). Otherwise I'd have needed a way to force a signal to go green.
I still don't see any way of connecting wagons behind a 1-directional engine automatically. But that's just a game limitation, not letting engines drive backwards when in automatic mode.
Anyway,
Re: [0.15] Automatic Coupler
Posted: Thu Jun 15, 2017 10:28 am
by Daelin
Any news about that update? Currently automatic coupler desyncs my game or kills the server I'm using. I also have the YIR train mod on, and once I try to couple wagons to a set of switchers the game desyncs.
Re: [0.15] Automatic Coupler
Posted: Thu Jun 15, 2017 10:30 am
by GotLag
I've been busy at work, hope to get something done this weekend.
Re: [0.15] Automatic Coupler
Posted: Tue Jul 04, 2017 3:32 pm
by Daelin
Will there be an update for the new Factorio version?
Re: [0.15] Automatic Coupler
Posted: Wed Jul 12, 2017 9:04 pm
by Daelin
Still no update?
This mod really helps with the trains. It would be great if there would be an update.
Re: [0.15] Automatic Coupler
Posted: Wed Jul 12, 2017 9:09 pm
by GotLag
Sorry, no idea what makes it desync, so I don't know how to fix it.
Also, working with the train API is a headache so I've lost much of my interest in rewriting this mod.
Re: [0.15] Automatic Coupler
Posted: Sun Aug 13, 2017 7:03 am
by vortex1967
Hi all,
It has taken a lot of head scratching and many hours to achieve but I have just finished a fully functioning network that processes a 16 wagon ore train, breaks it down to 2 wagons
puts those wagons into a loading or unloading area, retrieves the empty or full wagons, joins the wagons back together up to the 16 wagons ready to be connected
to the back of a 3 locomotive train to transport the empty or full wagons to their destination.
If enough interest is shown I could post some images and a summarized description of how it works.
Re: [0.15] Automatic Coupler
Posted: Sun Aug 13, 2017 7:41 am
by bNarFProfCrazy
vortex1967 wrote:Hi all,
It has taken a lot of head scratching and many hours to achieve but I have just finished a fully functioning network that processes a 16 wagon ore train, breaks it down to 2 wagons
puts those wagons into a loading or unloading area, retrieves the empty or full wagons, joins the wagons back together up to the 16 wagons ready to be connected
to the back of a 3 locomotive train to transport the empty or full wagons to their destination.
If enough interest is shown I could post some images and a summarized description of how it works.
Nice. I'm very interested in this. Please also include a blueprint.
Re: [0.15] Automatic Coupler
Posted: Sat Aug 19, 2017 4:07 pm
by vortex1967
Hi all,
Sorry, in advance for the long post. There is a lot involved in getting this mod to work automatically with no, or very little intervention by the player.
The station at the smelters uses an expanded and adapted version of the outpost design.
All the following images are taken from the station at the smelters.
At the moment designs have been laid out into sections for ease of trouble shooting.
Blueprints...I am using the 'Lighted Power Pole Mod' and all the signal wires are run along these poles. I will have to redo all the logic stuff onto vanilla poles.
Outpost overview:
Outpost Overview
Outpost overview.jpg (490.08 KiB) Viewed 12691 times
Smelters overview:
Smelters Overview
Smelters overview.jpg (291.17 KiB) Viewed 12691 times
1Wagon delivery:
Wagon Delivery
1Wagon delivery.jpg (341.73 KiB) Viewed 12691 times
Delivery trains arrive from the right into the delivery station and uncouple their wagons.
Delivery trains are 3 locomotives and 16 wagons long.
The locomotives then wait to the left until more ore is required.
2Breakdown_Dispatch:
Breakdown and Dispatch
2Breakdown_Dispatch.jpg (1.27 MiB) Viewed 12691 times
There are 4 waiting to be dispatched(breakdown)stations, 1 per ore, with 4 breakdown bays each.
A bay has a capacity to hold 8 wagons. The reason I have chosen 8 is mentioned further down.
The splitting in half train will not enter a bay that has wagons, it can only enter an empty bay.
When the breakdown station for a particular ore has been emptied of wagons it triggers the corresponding four locomotive train waiting to the right to be dispatched to the wagon delivery station to collect another 16 wagons.
It returns to the breakdown station where it splits those 16 wagons into 8, as can be seen at the Coal splitter.
They are split into 8 because double header trains would struggle to move 16 wagons in a timely fashion.
At the moment I am still doing testing, so the splitting stations are configured to only accept 16 wagons.
3Load_Unload:
Load_Unload
3Load_Unload.jpg (760.13 KiB) Viewed 12691 times
When a breakdown bay has wagons, that bay is opened for double header trains to arrive and disconnect 2 wagons.
They then proceed to the load/unload bays via the turn around bay. The turn around bays also refuel the trains.
If any of the load/unload bays are occupied they will wait in the waiting bays.
When a load/unload bay becomes vacant a train will proceed, uncouple it's wagons and return to a breakdown bay
where it collects another 2 wagons and so the cycle continues.
If any of the the breakdown bays are empty the double header trains will proceed to next open bay.
4Snake stacker_joiner:
Snake Stacker
4Snake stacker_joiner.jpg (526.77 KiB) Viewed 12691 times
When any of the wagons at the load/unload bays become empty one of the locomotives waiting at the empty wagon
pick up bays proceeds to that load/unload bay and returns with the wagons to the snake stacker via the turn around.
At the snake stacker, wagons are coupled back together to form 2 rows of 8 wagons each.
The snake joiner joins those 2 rows of 8 back into 16 wagons and waits in its current position.
The snake stacker control has 2 functions:
When a train enters a stacker line to add its wagons to the stack, the entry to that line is closed.
When the train leaves the line is re-opened.
and
If any of the stacker bays has its full stack of 8 wagons that line is closed.
The snake joiner control prevents the snake joiner from removing wagons from the bays until there are 2 full stacks of 8 wagons to join.
Snake locomotives:
When more ore is required, a 3 locomotive train assigned to that ore will proceed from where it has been parked
at the wagon delivery station to the snake locomotives bay. When it arrives it triggers the snake joiner train to position
its load of 16 empty wagons behind, when the snake joiner train has uncoupled it returns to it's position at the end
of the snake stacker, along the way passing 2 gates which trigger the snake locomotives to move to the train stop
just in front of it's waiting position where it connects to the 16 wagons waiting behind. It then proceeds to deliver the empty wagons to the outpost and return with a full load of ore.
The 3 forward facing locomotives aren't weighed down by dead weight locomotives that face backwards and can haul the 16 wagons at over 250kph in a short amount of time.
Some of the main statistics:
Each outpost: tracks-3332, rail signals-338, chain signals-134, train stops-62. There will be 4 outposts.
At the Smelter: tracks-9000, rail signals-1000, chain signals-381, trains stops-144. There is just 1.
There are some considerations:
This type of network wouldn't be suited to those that are looking for high through-put or efficiency.
It's more about the coolness factor of watching 16 wagons arrive, get split down to 2 wagons, sent through the system,
connected back together and emerge at the other end as 16 wagons again.
There are so many train stops that a naming convention has to be used to make it easier to name them.
For example: Smelt-Coal full delivery...for coal delivered to the smelters.
If I wanted to name the Copper delivery train stop at the smelters, I would select the Coal stop name and change
Coal to Copper which would then be Smelt-Copper full delivery.
It saves on a lot of typing and also the stop names are in alphabetical order when I get to setting destinations in the trains.
Granted there are a lot of train stops. But the majority of them are needed to be able to couple/uncouple the wagons.