Help with renaming train stations in schedules

Place to get help with not working mods / modding interface.
Aladrius
Inserter
Inserter
Posts: 23
Joined: Thu Jun 09, 2016 12:04 pm
Contact:

Help with renaming train stations in schedules

Post by Aladrius »

I'm working on a mod that updates a train station name using circuit network inputs, to allow stations to 'call' for trains based on conditions. What I've created so far is:

1> Copied and extended the base Train Station to a new item and entity "dynamic-train-station".
2> Set up recipe, research, etc for the Dynamic Station
3> Station will update its name if the name includes a | character. It updates the portion after the |.
4> Dynamic Stations poll their circuit network inputs looking for the "signal-red" and "signal-green" values, and reset their names based on the highest value input on one of those, or clears the name if both are zero or less. Red wins in a tie.
Example of how this works -- name the station "Iron|Whatever" -- at the next polling interval the station will be renamed to "Iron|", "Iron|Red" or "Iron|Green" depending on the circuit network inputs.

The main issue I'm running into is that when I reset the station name via the entity.backer_name property, it changes the name in the schedule of any trains that have that station. Currently, I can work around this by having a separate chunk of rail with a bunch of dummy stations on it matching the potential names that can be set. As long as there is still a station matching the existing name in the schedule, the name in the schedule won't change.

Using the dummy stations, if the dynamic station is changed to a name not in the schedule, the station is marked unreachable and the train stops wherever it is in its current route, usually at the previous station and blinks the "No Route" message.

Ideally, the functionality I'm looking to match is what happens when you pick up a station that's currently routed -- the train marks the name red and skips over it when it comes up in the schedule.

I want to keep this fairly lightweight, not getting deep into the guts of how trains schedule & route, so that managing the logic of the train network uses the in game tools as much as possible (combinators, etc).
Post Reply

Return to “Modding help”