mods icon indicating copy to clipboard operation
mods copied to clipboard

[BUG] Infinite Ores mod removes regular ore.

Open Pezzawinkle opened this issue 1 year ago • 3 comments

Ore patch generation works as intended with refining, but only the infinite patches (and regular coal) spawn with infinite ore mod active.

Pezzawinkle avatar Apr 19 '25 06:04 Pezzawinkle

I started looking at this but didn't get super far, but I figured I could add some notes.

Ore gen works with just angels+refining enabled angels+refining and bobs ores

but it fails in both cases if I add infinite ores (by fails, I mean only infinite ore patches are generated)

It also fails when refining is the only mod active (for another separate reason, particles aren't playing nice right now) but it also runs into issues with resource generation not working as expected (ie no normal iron patches, only infinite; copper was weird, it would generate tiny normal patches but I didn't see infinite patches of copper)

I am able to spawn ore patches in manually using the console.

My best guess is that something during map/chunk generation is being overwritten when infiniteores is loaded. (but I'm having a hard time finding exactly what it is)

I'm still poking around at it. The game doesn't seem to generate any starting ore patches, even when it should. Below is an output printing input.autoplace.starting_area

4.606 Script @angelsrefining/prototypes/generation/resource-builder.lua:1065: { ["angels-fissure"] = false, ["angels-natural-gas"] = false, ["angels-ore1"] = true, ["angels-ore2"] = false, ["angels-ore3"] = true, ["angels-ore4"] = false, ["angels-ore5"] = true, ["angels-ore6"] = true, coal = true, ["crude-oil"] = false, ["infinite-angels-ore1"] = false, ["infinite-angels-ore2"] = false, ["infinite-angels-ore3"] = false, ["infinite-angels-ore4"] = false, ["infinite-angels-ore5"] = false, ["infinite-angels-ore6"] = false, ["infinite-coal"] = false }

And I pulled logs looking at resource_index (this one wasn't super helpful?):

4.397 Script @angelsrefining/prototypes/generation/resource-builder.lua:1055: { ["angels-fissure"] = 27, ["angels-ore1"] = 21, ["angels-ore2"] = 22, ["angels-ore3"] = 23, ["angels-ore4"] = 24, ["angels-ore5"] = 25, ["angels-ore6"] = 26, coal = 0, ["crude-oil"] = 5, ["infinite-angels-ore1"] = 21, ["infinite-angels-ore2"] = 22, ["infinite-angels-ore3"] = 23, ["infinite-angels-ore4"] = 24, ["infinite-angels-ore5"] = 25, ["infinite-angels-ore6"] = 26 } 4.420 Loading mod angelsinfiniteores 1.0.0 (data-updates.lua) 4.446 Script @angelsrefining/prototypes/generation/resource-builder.lua:1055: { ["angels-fissure"] = 27, ["angels-ore1"] = 21, ["angels-ore2"] = 22, ["angels-ore3"] = 23, ["angels-ore4"] = 24, ["angels-ore5"] = 25, ["angels-ore6"] = 26, coal = 0, ["crude-oil"] = 5, ["infinite-angels-ore1"] = 21, ["infinite-angels-ore2"] = 22, ["infinite-angels-ore3"] = 23, ["infinite-angels-ore4"] = 24, ["infinite-angels-ore5"] = 25, ["infinite-angels-ore6"] = 26 }

Hopefully something here is helpful. I'll probably look at it again in the future.

EmZaid avatar May 03 '25 22:05 EmZaid

So here's roughly what's happening (Skipping some hopefully unimportant details):

The mod calls require("resource-autoplace").resource_autoplace_settings once for the normal and once for the infinite version:

resource_autoplace_settings{name="angels-ore1", patch_set_name="angels-ore1", autoplace_set_name="default", ...}
resource_autoplace_settings{name="infinite-angels-ore1", patch_set_name="angels-ore1", autoplace_set_name="default", ...}

resource_autoplace_settings goes and gets/creates a unique index based on patch_set_name and autoplace_set_name.

It then creates a noise expression named <autoplace_set_name>-<patch_set_name>-patches with the expression code resource_autoplace_all_patches{regular_patch_set_index=<index>, ...}

resource_autoplace_all_patches internally uses spot_noise{skip_offset=regular_patch_set_index, ...}

Spot noise only creates identical spots when given identical values of skip_offset.

So there's a bit of a dilemma:

  • we use the same autoplace_set_name and patch_set_name for the normal and infinite version: they use the same name for the noise expression, effectively overwriting each other. That is what's happening right now.
  • we use a different autoplace_set_name orpatch_set_name for the normal and infinite version: The expressions will have a different skip_offset, and the spots don't align.

I haven't found a nice way of ensuring different names but identical index. (I might be confused about what exactly autoplace_set_name does. Need to check again when more awake).

So I've attempted a bit of hack: The name to index mapping is stored in a global called autoplace_sets. So I've manually set the infinite's index to be equal to the normal index:

if input.get then
        [...]
        autoplace_sets.default.regular.patch_set_indexes[input.name] =
          autoplace_sets.default.regular.patch_set_indexes[input.get]
       [...]
end

Now, both spawn. Although a bit overlapping, with the normal ore only peeking through in a few places. I think that might be just the autoplace parameters requiriung a little tuning? Maybe? Hopefully?

Edit: ok, I have no idea what's happening here. Created a forum post for it: https://forums.factorio.com/viewtopic.php?t=130808

TODO:

  • double check that whole index building logic
  • figure out why the spots are overlapping the way they are (yay, noise expression debugging)
  • pretend the hack is ingenious (or come up with a better solution.)
  • figure out if there's some mod out there that has already figured out how to do all of this

Keithenneu avatar Sep 08 '25 20:09 Keithenneu

I've merged the linked PR which hopefully should fix this. It could do with some additional testing though!

KiwiHawk avatar Dec 21 '25 23:12 KiwiHawk

Bug report: https://forums.factorio.com/viewtopic.php?t=131528

KiwiHawk avatar Dec 29 '25 02:12 KiwiHawk