Page 1 of 1

How to detect a load that has had items removed due to missing mods?

Posted: Fri May 10, 2019 6:55 am
by adamius
Hi

I've got a mod that needs to recover from other mods being removed.

example situation:
1. you have mod A, B, C enabled at time of save.
2. you quit the world and disable mods B and C in Factorio.
3. you restart Factorio and reload the save.
4. Factorio removes the entities etc on loading of the save.
5. Mod A crashes because it relies on mod B and C.

How should I fix mod A so it can detect that mod B and C are no longer present?

What event should I have a handler to react to this situation?

thanks

Re: How to detect a load that has had items removed due to missing mods?

Posted: Fri May 10, 2019 6:59 am
by Bilka
On configuration changed is the event that you will want to use. Its event data provides you with the mods that were removed so you can very easily react to the change.

Re: How to detect a load that has had items removed due to missing mods?

Posted: Fri May 10, 2019 7:04 am
by darkfrei
On_configuration_changed check entity.valid and/or check that the prototype exists.
https://lua-api.factorio.com/latest/Lua ... on_changed

Re: How to detect a load that has had items removed due to missing mods?

Posted: Fri May 10, 2019 7:05 am
by adamius
worked like a charm. thanks.