[2.0.73] on_train_changed_state fires twice with incorrect info
Posted: Thu Feb 05, 2026 8:07 am
Create train. Add schedule to train. Switch train from manual mode to automatic mode.
on_train_changed_state will now fire twice. The first will correctly include event.old_state == defines.train_state.manual_control and correctly changes the trains current state to on_the_path (or no_path or destination_full if appropriate).
Then on_train_changed_state fires again. This time it incorrectly includes event.old_state == defines.train_state.no_schedule. Not only is this old_state incorrect (for either before or after the previous on_train_changed_state event), but it is also redundant.
This second event should not fire.
on_train_changed_state will now fire twice. The first will correctly include event.old_state == defines.train_state.manual_control and correctly changes the trains current state to on_the_path (or no_path or destination_full if appropriate).
Then on_train_changed_state fires again. This time it incorrectly includes event.old_state == defines.train_state.no_schedule. Not only is this old_state incorrect (for either before or after the previous on_train_changed_state event), but it is also redundant.
This second event should not fire.