Add train_changed_state event for waypoints

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Add train_changed_state event for waypoints

Post by mrvn »

TL;DR
When a train passes a waypoint a train_changed_state event should be send.
What ?
When a train aproaches a station the arrive_station (old state: on_the_path) event should be send even if the station is then skipped because it is a waypoint. Logically a on_the_path (old: arrive_station) event would follow that because the train is on the move again and not breaking. Alternatively a on_the_path (old: on_the_path) could be send because the train is now on a new path.

This could also be used to send an on_the_path (old: on_the_path) event when the user changes the station the train drives to in the schedule (but doesn't change the schedule) or even when a train repaths resulting in a different train stop. Basically whenever the path changes destinations.
Why ?
There is no way for mods to detect when a train passes a waypoint. The events actually recieved become confusing because a train will leave station A for station B but next it arrives on station C from station B, skipping station B in the flow completely. There is also no way to detect when a train is interfered with by the player sending it somewhere else (without changing the schedule).

For my Logistic Trains mod I need to keep track of trains and one station design I would like to support is to have a large station with multiple unloading bays and a single waypoint station at the entry into the train yard. The moment the train skips the waypoint station I want to assing a specific unloading bays to the train (by way of setting a temporary stop) so I can direct the train to the unloading bay with the least amount of buffered items and more importantly one that has enough buffer space to unload the train fully.

But for that I must know when the train actually advances the schedule to the unloading bays.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Add train_changed_state event for waypoints

Post by ssilk »

This is a mod interface suggestion, moved out from suggestions.

I would implement a new event, because it is a difference if a train comes to a station, or if it passes. That also would not break mods, that already implemented their functionality on the current state.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Post Reply

Return to “Modding interface requests”