Page 1 of 1

Add train_changed_state event for waypoints

Posted: Mon Aug 03, 2020 7:42 pm
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.

Re: Add train_changed_state event for waypoints

Posted: Fri Aug 07, 2020 5:52 am
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.