[2.1.14] Allow train stop LuaEntity when adding a record to LuaSchedule
Posted: Tue Aug 18, 2026 6:41 pm
Rationale:
Both CyberSyn and LTN use "temporary rail stops" to direct trains to a specific train stop because the station attribute only accepts a station name which is ambiguous if multiple stations with the same name exist. However, it is possible to pass in a LuaEntity representing a rail as the "rail" attribute.
I am suggesting to implement allowing a LuaEntity to be passed in as the "station" attribute which would make these workarounds go away. The LuaTrain object already has a station attribute that returns a LuaEntity
Suggested API changes:
ScheduleRecord would get a new attribute, e.g. "station_entity LuaEntity?" to read back the LuaEntity. This can be nil if only a station name was set. If 2.1 is still considered unstable, the return type of "station" could be changed to LuaEntity? and a new attribute station_name that returns string? could be added. This would then align with both LuaTrain and TrainStopFilter
TrainStopFilter could get a new attribute "station" which would filter by LuaEntity or array[LuaEntity]?
(I am leaving WaitCondition / BlueprintScheduleRecord alone as those are more important for player interaction; the API changes above would benefit mods that implement automatic train scheduling)
Suggested Behavior changes:
It is also possible today to add station names to the schedule that do not exist / exist on a different surface. This is not possible for rails (specifying a rail LuaEntity in rail = that is not on the same surface results in an error). It should be possible for both rails and the suggested station LuaEntity elements to add ScheduleRecords where the entities are on a different surface. This will allow mods to "send" trains between surfaces without all the workarounds/kludges needed today to manage the schedule. If a station / rail is not reachable in the schedule, the train should should show a "no path" error as it does today for a station name that exists but is not on the same surface.
With 2.1 slowly stabilizing, this would be a great time to implement this before a first stable release.
Both CyberSyn and LTN use "temporary rail stops" to direct trains to a specific train stop because the station attribute only accepts a station name which is ambiguous if multiple stations with the same name exist. However, it is possible to pass in a LuaEntity representing a rail as the "rail" attribute.
I am suggesting to implement allowing a LuaEntity to be passed in as the "station" attribute which would make these workarounds go away. The LuaTrain object already has a station attribute that returns a LuaEntity
Suggested API changes:
ScheduleRecord would get a new attribute, e.g. "station_entity LuaEntity?" to read back the LuaEntity. This can be nil if only a station name was set. If 2.1 is still considered unstable, the return type of "station" could be changed to LuaEntity? and a new attribute station_name that returns string? could be added. This would then align with both LuaTrain and TrainStopFilter
TrainStopFilter could get a new attribute "station" which would filter by LuaEntity or array[LuaEntity]?
(I am leaving WaitCondition / BlueprintScheduleRecord alone as those are more important for player interaction; the API changes above would benefit mods that implement automatic train scheduling)
Suggested Behavior changes:
It is also possible today to add station names to the schedule that do not exist / exist on a different surface. This is not possible for rails (specifying a rail LuaEntity in rail = that is not on the same surface results in an error). It should be possible for both rails and the suggested station LuaEntity elements to add ScheduleRecords where the entities are on a different surface. This will allow mods to "send" trains between surfaces without all the workarounds/kludges needed today to manage the schedule. If a station / rail is not reachable in the schedule, the train should should show a "no path" error as it does today for a station name that exists but is not on the same surface.
With 2.1 slowly stabilizing, this would be a great time to implement this before a first stable release.