Migrated Content Event ?

Place to get help with not working mods / modding interface.
Post Reply
TreefrogGreaken
Long Handed Inserter
Long Handed Inserter
Posts: 58
Joined: Thu May 04, 2017 12:07 pm
Contact:

Migrated Content Event ?

Post by TreefrogGreaken »

Hello Modders!

Simple enough question really.

Is there an event that gets raised when Factorio shows the Migrated Content window?

Specifically I'm looking for an event that gets raised which would contain the entities that have been removed from the save file.

Having issues with my mod, if Factorio decides to remove an offshore pump for example, then my mod needs to know about it so I can adjust the data for my mod to run correctly. Currently the count of offshore pumps will be off, and there doesn't appear to be anything I can do to fix this. Another mod is causing a fluid mixing conflict and Factorio is removing the offshore pumps to load the save, which if i knew was happening, I could correct the data in my mod.

I did a search and didn't find anything specifically for this issue, though it looks like there are a few posts about an a similar request regarding uninstalled entities.

Only other way I can think to get this fixed, would be to have my mod periodically scan the areas to see if there's any change, though that would be a performance impact, or do a scan on map load again which would be a performance hit. Other then this, it would be to get the other authors mod fixed so it doesn't cause mine an issue.

Any help / advice would be great.

Thanks

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3466
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Migrated Content Event ?

Post by DaveMcW »

Code: Select all

script.on_configuration_changed(function(event)
  local count = 0
  for _, surface in pairs(game.surfaces)
    for _, pump in pairs(surface.find_entities_filtered{type="offshore-pump"}) do
      count = count + 1
    end
  end
  global.count = count
end)

Rseding91
Factorio Staff
Factorio Staff
Posts: 11928
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Migrated Content Event ?

Post by Rseding91 »

You want https://lua-api.factorio.com/latest/Lua ... s_filtered not find_entiteis_filtered since you don't actually want a LuaEntity per found one - just the count.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”