Railway Tunnel (Alpha)


A railway tunnel so trains can cross under each other. An ALPHA release to demonstrate the concepts and completed functionality so far.

Content
2 years ago
1.1
2.01K
Transportation

b [Fixed] Fatal error if the player tries to drive through a tunnel on a train.

2 years ago

The game throws an error if I try to drive through a tunnel on a train:
Error while running event railway_tunnel::on_entity_died (ID 4)
railway_tunnel/scripts/portal.lua:1338: suspected player driving train
stack traceback:
[C]: in function 'error'
railway_tunnel/scripts/portal.lua:1338: in function 'OnPortalEntryTrainDetectorEntityDied'
railway_tunnel/scripts/tunnel-shared.lua:442: in function 'handlerFunction'
railway_tunnel/utility/events.lua:158: in function <railway_tunnel/utility/events.lua:151>

2 years ago
(updated 2 years ago)

Oh, I'm surprised you managed to get as far as making it error, manual trains should be stopped at the tunnel entrance and prevented from entering the tunnel portal. Manual trains aren't supported at present and I thought I'd protected against it well enough.

As the error message includes the text railway_tunnel/scripts/portal.lua:1338: suspected player driving train there is a hard error to protect against the code even trying to handle this un-supported situation.

From mod description (yes its a very long page I know):

Manually driven trains can not use a tunnel. They will be stopped at the tunnel portal entrance track or from entering the underground part of the tunnel. There is a known limitation documented in relation to a contrived scenario that will cause a crash for player driven trains.

Chrome highlighted text link: https://mods.factorio.com/mod/railway_tunnel#:~:text=Manually%20driven%20trains%20can%20not%20use%20a%20tunnel.%20They%20will%20be%20stopped%20at%20the%20tunnel%20portal%20entrance%20track%20or%20from%20entering%20the%20underground%20part%20of%20the%20tunnel.%20There%20is%20a%20known%20limitation%20documented%20in%20relation%20to%20a%20contrived%20scenario%20that%20will%20cause%20a%20crash%20for%20player%20driven%20trains.

2 years ago

did you do anything special to try and force the train through the tunnel in manual, or have any mods that add faster trains or something?

As when driving a train in manual up to the start of a tunnel portal it should stop the train on the outside of the portal and display text saying manually driving trains through tunnels is unsupported.

2 years ago

I am once again creating a new mod pack for my production madness. I test almost every mod separately, so only your mod was installed. Tunnels for trains could significantly dilute my boring railway designs.
How did I get the error? I built a tunnel. First, the train rolled from station to station without a passenger. Then I got on the train and went manually through the tunnel and got an error.

Sorry. I am bad in English.

2 years ago

Oh, you are right, this just errors on normal use. I can reproduce this now I'm back on a computer to test.
I thought I had added protection against this, apparently not very well.

Thanks for the report.

2 years ago

a nice message is shown to the player without an error in next mini release of the mod.

2 years ago

I tested mod and now everything works well. I also noticed that train can travel through tunnel in automatic mode, even if player is inside.

2 years ago

Yes a player can ride a train through the tunnel fine. But they can't manually drive it.

If a player takes manual control of a train once it starts using a tunnel the mod will still crash. This is a limitation of where the Alpha got to in its development.