Train Control Signals

by Klonan

Simple ways of controlling trains.

Content
3 years ago
1.1
25.3K
Trains

g [SE] Doesn't work with Space Elevator

1 year, 10 months ago

I think because of this https://mods.factorio.com/mod/Train_Control_Signals/discussion/624c53477eab1e6dd0f2230f it doesn't work with the space exploration mod with the space elevator.

1 year, 7 months ago

Indeed this does seem to be the case. Can this be looked into please?

1 year, 6 months ago

I created a janky fix for myself. It probably doesn't account for cases I haven't run into, but I've been using it for when a fuel or depot station is right after an elevator.

https://gist.github.com/rfvgyhn/0ad8c7ee4ad7762a4f339b83b9d4e8ec

You can apply the patch file with patch or just manually make the changes to your local copy.

1 year, 6 months ago

Seems to work as long as your trains are at least 3 units long. But a train consisting of a single locomotive and a wagon or less will crash. Thanks anyway.

1 year, 6 months ago

That's interesting. My current game consists of 99% 1-1 trains.

1 year, 6 months ago

hmm strange. Well my sample size was rather small with 1 train of each size, I will probably use. Will do some more testing in the future in case something else is involved.

1 year, 6 months ago

OK, I think I found out the reason for the crash. Had nothing to do with the train size. It always crashs for me, if the depot station was already marked as skipped in the schedule (contains the skip signal).

1 year, 6 months ago

Here the full crash log if that is helpful:

Error while running event Train_Control_Signals::Custom event (ID 376)
Must specify one of station or rail.
stack traceback:
    [C]: in function '__newindex'
    __Train_Control_Signals__/script/train_control_signals.lua:265: in function <__Train_Control_Signals__/script/train_control_signals.lua:236>
stack traceback:
    [C]: in function 'raise_event'
    __space-exploration__/scripts/space-elevator.lua:766: in function 'space_elevator_teleport_next'
    __space-exploration__/scripts/space-elevator.lua:1359: in function 'space_elevator_tick'
    __space-exploration__/scripts/space-elevator.lua:1386: in function 'callback'
    __space-exploration__/scripts/event.lua:15: in function <__space-exploration__/scripts/event.lua:13>
1 year, 6 months ago

Well looks like my save is broken. Just did a brand new world for testing and there it is working fine. Yikes.

1 year, 6 months ago

In your main game, does your elevator exit connect directly to a curved rail? It currently only looks for a straight rail.

1 year, 6 months ago

No, it exits to several straight rails. Otherwise it would have crashed in all cases and not just when the skip signal is present. I tried to debug it, but my main save won't even load when using the Factorio modding debug kit :(

1 year, 6 months ago
(updated 1 year, 6 months ago)

I found out the reason. Apparently there is no rail connected to my space elevator in my main save even though there are rails. No idea why. Will forward that as a space exploration bug.
And it didn't crash when no skip signal was present, because the crashing code was not run in that case.
I also forked your gist and edited compatibility to other rail directions and prevented my crash: https://gist.github.com/ChaosSaber/7d7f65f824af151cf0e68f07f9948a57 (Note: i did not change the .patch file)

1 year, 6 months ago
(updated 1 year, 6 months ago)

With the help of the SE developper BurninSun we found out that the orientation of the space elevator caused this behaviour. Depending on the orientation of the elevator, the exit is either on the front or the back of the rail the train spawns on.
I updated the gist to now work with both rotations. The waypoint was also moved inside the elevator to not force the train on a track, which it otherwise would not have gone and may get stuck there. This time i also updated the patch file.

1 year, 6 months ago

Good find. I do, however, still run into the issue I had when I tried to make it stop inside the elevator. It appears as though the TCS logic isn't getting re-evaluated so my trains gets stuck at the first rail outside the elevator when their destination doesn't have any reservations available instead of going to a depot.

1 year, 6 months ago

Do you by any chance have a mod which increase the size of a locomitve or a mod which introduces differently sized locomitives? In that case i could imagine that the logic no longer works and it does not set a temporal station it can drive to or the temporal station is at the exact position of the loco so it gets instandly removed.
Otherwise i do not yet actively use it. I only tested it in on several test cases. I'm still replaning my space and ground base to properly use it.

1 year, 1 month ago

Has anyone published a fork of TCS with the fix discussed here?

1 year, 1 month ago

As a work around I just added another station after the Space Elevator that the train always goes to. After the train goes through that the Train Control Signals mod works as expected. Would need a Work around station on both sides of the elevator if using the signals on both sides. I've got the depot and refueling in orbit so only need the work around after the upwards journey.

So my routing is Elevator -> "Work around station" -> Depot -> Refuel -> Drop off

New response