Page 1 of 1

Raise events when trains are removed

Posted: Thu Nov 23, 2023 6:32 am
by notnotatschool
I have a mod which displays information about trains. This information is updated whenever trains are created, split, enter or exit manual mode, and in a few other scenarios. However, it's not currently possible to tell whether a train has been completely removed due to its last rolling stock being removed without tracking when every rolling stock in the world is removed. I'd like an event called something like

Code: Select all

on_train_destroyed
that is raised when a LuaTrain is destroyed without any new train being created in its place like in

Code: Select all

on_train_created
.

Re: Raise events when trains are removed

Posted: Mon Dec 04, 2023 3:41 pm
by boskid
I think this may be considered as implemented for 2.0 as there was "register_on_object_destroyed" implemented which supports LuaTrain. In that case when a train is destroyed (where by train we should consider "specific composition of stocks" so 2 trains may be destroyed when merging them into 1 new train) it will raise a notification on_object_destroyed if you registered that train for notifications.