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

Place to get help with not working mods / modding interface.
adamius
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Mar 19, 2018 9:18 am
Contact:

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

Post 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
Bilka
Factorio Staff
Factorio Staff
Posts: 3464
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

On_configuration_changed check entity.valid and/or check that the prototype exists.
https://lua-api.factorio.com/latest/Lua ... on_changed
Last edited by darkfrei on Fri May 10, 2019 7:05 am, edited 1 time in total.
adamius
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Mar 19, 2018 9:18 am
Contact:

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

Post by adamius »

worked like a charm. thanks.
Post Reply

Return to “Modding help”