The issue I'm trying to solve is this: if a player uses this mod, it replaces some resource tiles with the infinite versions, then they save and add that resource to the exclusion list (restart the game), upon loading the save, all of the infinite versions of that resource are gone. I want to convert them back to non-infinite versions, if possible.
Code: Select all
require("__core__/lualib/util")
local exclusionlist = {}
for k, v in pairs(util.split(settings.startup["InfiniteResourcesNormalYieldDepletion_exclusions"].value, ",")) do
exclusionlist[v] = true
end
for _, surface in pairs(game.surfaces) do
local resources = surface.find_entities_filtered{area = nil, type = "resource"}
for _, resource in pairs(resources) do
log(resource.name)
if resource.initial_amount and exclusionlist[resource.name:gsub("-infinite", "")] then
resource.surface.create_entity({name = resource.name:gsub("-infinite", ""), amount = resource.amount, position = resource.position, force = game.forces.neutral, raise_built = true})
end
end
end
How do I get them? Is this possible?