Page 1 of 1

Migrated Content Event ?

Posted: Sun Jul 14, 2019 12:02 am
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

Re: Migrated Content Event ?

Posted: Sun Jul 14, 2019 1:02 am
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)

Re: Migrated Content Event ?

Posted: Sun Jul 14, 2019 1:59 pm
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.