When adding/removing carriages to an automatic train parked at a train stop it switches to manual without raising on_train_changed_state.
Expected behavior would be to raise on_train_changed_state(event.train.state = defines.train_state.manual_control)
[0.14.21] on_train_changed_state does not always fire
Re: [0.14.21] on_train_changed_state does not always fire
In that instance the state is not changing. The old train is deleted and a new train in a different state is created. Thus no event is fired.
That's expected behavior.
That's expected behavior.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.14.21] on_train_changed_state does not always fire
Is there an on_create event fired or do you have to check for this in on_tick?
My Mods: mods.factorio.com
Re: [0.14.21] on_train_changed_state does not always fire
You should be able to find some ideas on how to handle this by looking at smart-trains mod or stdlib/trains stuff.Optera wrote:Is there an on_create event fired or do you have to check for this in on_tick?
Re: [0.14.21] on_train_changed_state does not always fire
Quite some hacks needed to get a train stop notice changed train states reliably through on_built_entity, on_preplayer_mined_item, on_entity_died.Nexela wrote:You should be able to find some ideas on how to handle this by looking at smart-trains mod or stdlib/trains stuff.Optera wrote:Is there an on_create event fired or do you have to check for this in on_tick?
It still feels like on_train_changed_state should fire when creating a new train with the same unit numbers, backer names and object references.
My Mods: mods.factorio.com