Automatic Coupler 0.16


Adds signals to allow stations to couple/uncouple trains automatically.

Content
6 years ago
0.16
4
Trains

g switching to manual

6 years ago

after coupling or decoupling the train switches to manual. is this fixable?

6 years ago

This confuses me.. I know this happens for the older version of the mod (https://mods.factorio.com/mod/Automatic%20Coupler), but switching to manual is one of the things that this update should fix. Are you sure you were using the right mod?

6 years ago

I just double checked. I did have previous versions installed, I uninstalled all of them. then I reinstalled your mod and the issue continued to occur

6 years ago

Do you have any other mods enabled? I personally can't reproduce this issue. Please try again in a new, clean save. Maybe something got corrupted somewhere.

6 years ago

I have the same issue. Once I uncouple it swiches to manual. I got the following mods installed:
auto-research_4.2.0
Automatic_Coupler_016_1.0.3
Chainsaw_1.16.0
FuelTrainStop_0.16.1
longer-belts-redux_0.16.1
research-queue_1.6.7
Side inserters_2.3.4
TrainSpeedLimit-016_1.2.0
tree_collision_0.4.2
yi_railway_0.6.21
Yuoki_0.6.74
z_yira_american_0.6.8
z_yira_yuokirails_0.6.12

6 years ago
(updated 6 years ago)

Hi,

I checked again because I had the same issue.
The problems are the modded trains as I tested it with Bob's Logistics.
It searches for the name "locomotive". But it has to be the exact same string.

Maybe Timmiej93 can change the control.lua and replaces line 93 and 99
from:
if carriage.name == "locomotive" then
to:
if string.find(carriage.name, "locomotive") then

I don't now how the Yuoki Trains are named ingame but you could add mod support be just adding a string that is available on all train names.
it the should look like this with "train" as example:
if string.find(carriage.name, "locomotive") or sring.find(carriage.name, "train") then

Hope this helps ;)

EDIT: The string you use should not be included in any wagon name!!

6 years ago

I honestly have pretty much given up on this mod. I initially uploaded it because I converted it to work in 0.16 for myself, and thought: why not share it. However, after a while I found out that it's incompatible with the Smarter Trains mod, which I heavily depend on. Coupling / decoupling would be a great function for Smarter Trains, which I also mentioned over there, but to this day, no response. I'll make sure to implement the improvement you suggest here, and will upload asap. Hopefully that'll help some of you out.

6 years ago

Awesome! Thanks SWATim for looking into the issue! And thanks to you Timmie for planning to update the code!
I'll look forward to the update!

6 years ago

It should already be uploaded ;). Version 1.0.4

6 years ago

So, I downloaded the update, but it did not work (yet).
Thing is, I hardly understand anything about coding. However, I checked the lua files from the Yuoki Railway mod, and the locomotives in there have names like:
name = "yir_loco_del_mk1400",
name = "yir_loco_fut_red_recipe",
name = "yir_loco_del_KR"

(all are type "locomotive")

So I thought, well SWATim said to change the string the control.lua from the automatic coupler looks for to something that is contained in the name of the Yuoki locomotives.

According to that I changed the two lines as follows:

if (string.find(carriage.name, "loco")) then

And had my friend (who runs our small server) update the mod again with that change.

Still had the trains switch to manual on uncoupling the waggons...

But I was using a very specific locomotive (a red german shunting engine), maybe that one has a different name?
After a longer search I found that the locomotive I'm using has the following name (as far as I can tell):

name = "yir_lsw_r790red",

Sadly, at that point my friend was already offline, so I could not test it on the server yet. (And I was too sleepy/frustrated to try and rebuild all the tracks and switches for the test layout on a singleplayer map)

I will check if I can get my friend to update and test it tomorrow. Just wanted to let you guys know.

I also have a savegame file, if that would help in any way. But I can't attached anything here. Maybe we could make a forum thread for this?

Anyways, thanks for your help guys! I still hope we get this to work! :-)

6 years ago

IT WORKS!!! IT F***ING WORKS! Yes! I changed/added the control.lua as followed:
...or string.find(carriage.name, "lsw") then...
And it works! Fully automated trains! :-D

6 years ago

Should be all implemented. Thank you for investigating and reporting, you're helping out other people here!

Also, what you were doing today and yesterday is exactly how I got into coding. Start with changing some tiny things, and grow from there. Who knows, maybe some day you'll be a pro ;).

6 years ago

Thanks for the kind words, and also for the quick update! Much appreciated!

6 years ago

Couldn't you use carriage.type = "locomotive"???

6 years ago

Not a clue honestly, I haven't looked into this stuff at all, I just converted it with instructions of others. It does make a lot of sense though, so if anyone running any train mods would like to check this out, that'd be great.

6 years ago

Laendra, could you post an example? I just have no real clue how to code.
Would it be like this:

if (carriage.type = "locomotive") then
frontLocos = frontLocos + 1

6 years ago

It's pretty much the same as what you've done before. Where you did:

if (string.find(carriage.name, "loco")) then

It'd now be:

if (string.find(carriage.type, "locomotive")) then
or
if (carriage.type == "locomotive") then

I'm not sure which of the above is better, but with strings, I'd go with the string.find version.

Note the double = here.
A single = means you're assigning. For example a_value = 1 sets the variable a_value to 1. Therefore, a_value + a_value would be equal to 2.
A double = means you're comparing. For example 2 == 2 would result in true. 2 == 1 would result in false.

6 years ago

Tested it today! Works! Now I can use all locomotives, regardless of what their name is.
I used the line: if (string.find(carriage.type, "locomotive")) then
Thanks for your support guys! :-)

6 years ago

Thanks again for testing! I've updated the mod accordingly, so hopefully now every train mod will work.

5 years ago

Hiho! Can you please update the mod? I couldn't enjoy factorio to its fullest without the automatic coupler! :-)

New response