[0.15] Automatic Coupler

Topics and discussion about specific mods
GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

[0.15] Automatic Coupler

Post by GotLag »

Mod Portal

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
Image
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
Last edited by GotLag on Sun May 28, 2017 6:40 am, edited 3 times in total.

driver
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Wed Oct 28, 2015 11:24 am
Contact:

Re: [0.15] Automatic Coupler

Post by driver »

Could you please take a screenshot and explain how this works?
I have no idea how circuits work in combination with coupling. ;)

bNarFProfCrazy
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sat Apr 23, 2016 7:11 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: [0.15] Automatic Coupler

Post 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.

driver
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Wed Oct 28, 2015 11:24 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

bNarFProfCrazy
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sat Apr 23, 2016 7:11 am
Contact:

Re: [0.15] Automatic Coupler

Post by bNarFProfCrazy »

I managed to build a single headed switcher train station.
Switcher-Ffront-Cargo
Switcher-Ffront-Cargo
Switcher-FrontCargo.png (1.26 MiB) Viewed 7354 times
Switcher-Ffront-Cargo-Zoomed
Switcher-Ffront-Cargo-Zoomed
Zoomed.png (1.13 MiB) Viewed 7354 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.

BLueprint:

Code: Select all

0eNrVm19u4zYQxu/Cx0IK+F+yXxfoBdq3IjBkmXEEOJIhy2mDwAfoLXq2nqSU5Nhemdx846Tb7ouzlsWfNPNxyJmR9pUtN3u3bau6Y/NXVpVNvWPz317ZrlrXxaY/1r1sHZuzqnNPLGF18dR/a4tqww4Jq+qV+4PNxSF5d0jnx9Tprmu2FwNlcOBz1XZ7f+Q0djwjLZv9duMuhivS8H19BdCH+4S5uqu6yo2GD19eFvX+aelab9lXJqfl42DEeMWEbZudH9nU/cV7N/A7k7AXNk+zO+MvsqpaV46/D4ZO2PLELvfts1ulg1evqSNyArQBoMKAGQzUZxf28q0fuwjSjkj7vtEGReYw0qJIwWFmBjMlzMxhpoaZM5iJS9S7CYTiIgmBQiWukpAwFJdJKBiK6yTgUJIEoeBgkgSh4HBSBKHgeFIEoeCAUgSh4IhSuFASjiiFCyUFttynxz1JAEhJ2e5S9bbdqel2J0JwOK6OasmvmVmIqSk3fLpfDd2v+Zr9/q5/hQ3tqdKGUqLoRNAT1RJWNpum7c8a05P18LkcPgs253d6lnM1k8L4P0LbQ+geMpLO0rxZKKC85hyXfT7ZFXXnU7enZVUXnb/zb/HllK97e+uubTaLpXssnqvR9Idq07k2kqoi+Z//V5/yyosU9n44XNfjpXc9UPQf69a5+jI3rFZ+4MyfH3TtDJI3leFJbsP2DqhFj9q61QK2+Fd2IBmV90Z9ygxTHAueVErS3FIC5fI4N+zjsmrLfdUtyk2zcycfPxSbnUtOP7auOPu/a/f+p9Yr0uy77b7DhRndHxPHE6fSWBWZb0qCDhFRf5jP9UfTFvXakV3SG01xSH6+if67iPkHz+YG9/D3Nx2lachpjKsQ01BW5Ph6aUJsOKNLjzkNBwIxw6EahuY4VMLQGQ7lKFTDGV16zL0RqMChsFBa4lBYKK1wKCyU1jgUFwqukVKBC4VHlMCFwiNK4ELhESVwofCIErBQBo8oWCeDBxQsk8HjCVbJEMIJZsLRNEoEVFvG0JDIXdoPIUNbqck+tOMH7zKnla4I8hxDy2qduo0/ua3KdNv4AiWwM41NW0VJ5+2ld4YcifNIlmT5rSXbv1qxXdVr4tZ6zcqY5XBB8WbxVf5sKfnzmCMH0+dJau2Zq9MdPFTtjl5fJCc1B9d5RbdFOyg6Z3//+denFCBWkgpeCdVi36fetfy63uUX9S7H612rSOF8TIoUwf9iEsxqesDa/mFW0FAzC5wbVlPTOkMyGhQhuKHBOQluSQrkZAGmq+m0ApVR918PjXWPbEbq6QINE3veuoq26h6fXOed8s213b4t7dDCfqaeV6zdDUvWUP9fLlipD8Jm6/x6NVye/eSH3NpnwWVWcthYZGwWRANnBu4jKrZxiv/fNnKlCWUTCYdCzH8Zv+nRA7Q0ZIKYXgMNmwzsu5EWyEyRnCDeenoaaZ1mmpjjnfDqx8jxMhObWwZLUY7FqobSu52rV4uuWQzEU9R9n8Ql05/WqM8suG7lpLlGe8AUncehdmZGaBKOuzzyvseM2iNFXvjg1B4pAhXUHikCldQeKQJV1B4pAtXUHikCNdQeKQK11B4pAs2oPVIEmlN7pAh0Ru2RIq87cWqPFIEKao8UgUpqjxSBKmKPFGFqYo8UYRpijxRhWmIShzAzWvcRQea07iOCnNG6j9ArfujzeZUd9+bsQ22v9x4bU7IfE6ueBRe0BoOK2haky9uyc5Cubk3P8x/lpRnBdVQ5TUrRc6iL+F+m6F7PWI7Oqc1FwWmNs5w28SzxDZIA9j4Z3/afX/x/goRtiqXzrmW//F515aNr059br9KXol03/tdnPxfH4VpLY7z9Ijsc/gEnVhrV
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-Desing
Requested-Design.png (1.36 MiB) Viewed 7354 times

driver
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Wed Oct 28, 2015 11:24 am
Contact:

Re: [0.15] Automatic Coupler

Post 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).

totalwar57
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed May 31, 2017 1:18 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

bNarFProfCrazy
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sat Apr 23, 2016 7:11 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: [0.15] Automatic Coupler

Post 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.

totalwar57
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed May 31, 2017 1:18 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

leoch
Fast Inserter
Fast Inserter
Posts: 134
Joined: Fri Dec 16, 2016 9:37 pm
Contact:

Re: [0.15] Automatic Coupler

Post 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,

Daelin
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Jun 15, 2017 10:23 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: [0.15] Automatic Coupler

Post by GotLag »

I've been busy at work, hope to get something done this weekend.

Daelin
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Jun 15, 2017 10:23 am
Contact:

Re: [0.15] Automatic Coupler

Post by Daelin »

Will there be an update for the new Factorio version?

Daelin
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Jun 15, 2017 10:23 am
Contact:

Re: [0.15] Automatic Coupler

Post by Daelin »

Still no update? :(
This mod really helps with the trains. It would be great if there would be an update.

GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: [0.15] Automatic Coupler

Post 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.

vortex1967
Inserter
Inserter
Posts: 40
Joined: Fri Apr 15, 2016 8:48 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

bNarFProfCrazy
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sat Apr 23, 2016 7:11 am
Contact:

Re: [0.15] Automatic Coupler

Post 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.

vortex1967
Inserter
Inserter
Posts: 40
Joined: Fri Apr 15, 2016 8:48 am
Contact:

Re: [0.15] Automatic Coupler

Post 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
Smelters overview:
Smelters Overview
1Wagon delivery:
Wagon Delivery
2Breakdown_Dispatch:
Breakdown and Dispatch
3Load_Unload:
Load_Unload
4Snake stacker_joiner:
Snake Stacker
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.

Post Reply

Return to “Mods”