Infinite Resources


Makes all resources infinite.

Tweaks
1 year, 7 months ago
0.17 - 2.0
82.8K
Cheats

g Disabling mod causes ores to deplete?

1 year, 7 months ago

I mistakenly enabled the mod in a specific game I wasn't planning to enable infinite resources and played several minutes (don't have a save file of game without mod enabled). When I realized the mistake and disabled the mod later, all the resource patches (even ones I hadn't touched yet) had depleted drastically. Is this expected and is there a way to bring them back to initial levels?

1 year, 7 months ago

Yes, even after deleting the mod, the save file is still corrupted. It's really frustrating.

1 year, 7 months ago

I found a console script that will regenerate all resources (on the planet you're currently on). It's adapted from this one on the Wiki (fixed an error since the API changed in 2.0).

/c local surface = game.player.surface
for _, e in pairs(surface.find_entities_filtered{type="resource"}) do
  if e.prototype.infinite_resource then
    e.amount = e.initial_amount
  else
    e.destroy()
  end
end
local non_infinites = {}
for resource, prototype in pairs(prototypes.get_entity_filtered{{filter="type", type="resource"}}) do
  if not prototype.infinite_resource then
    table.insert(non_infinites, resource)
  end
end
surface.regenerate_entity(non_infinites)
for _, e in pairs(surface.find_entities_filtered{type="mining-drill"}) do
    e.update_connections()
end

Running that will disable achievements for your save unfortunately. I'm not sure there's much I can do about it from my mod, it's not like I can have it run something when you remove it. The mod makes a permanent change to the worldgen so it's not really intended to be disabled.

10 months ago

Yes, even after deleting the mod, the save file is still corrupted. It's really frustrating.

I'm adding a feature to my mod that also makes all resources infinite. I ran into the same issue, but I managed to fix the bug. Instead of setting everything to 100%, I take the original value from the map and treat it as a percentage. So for example, if there are 35 units of a resource, I convert that to 35%. While mining in infinite mode, that 35% doesn't decrease. Then, when infinite mode is disabled, it correctly returns to the original value.

New response