Page 1 of 1

[Solved] MapGenSettings for Surfaces

Posted: Sat Oct 01, 2016 1:51 pm
by jkeywo
I'm generating a new surface and trying to provide it with it's own MapGenSettings, but it's not working like I'd expect.

The effect I'm after is to completely override the autoplace_controls with my own. I've tried...

Code: Select all

{ 
          ["nidavellir-floor"] = { frequency = "normal", size = "medium", richness = "regular" },
          ["nidavellir-wall"] = { frequency = "normal", size = "medium", richness = "regular" },
          ["nw-nifite-ore"] = { frequency = "normal", size = "medium", richness = "regular" } ,
}
Which has no effect on what is generated, ir mirrors the main surface exactly.

Trying this...

Code: Select all

{ 
          ["nidavellir-floor"] = { frequency = "normal", size = "medium", richness = "regular" },
          ["nidavellir-wall"] = { frequency = "normal", size = "medium", richness = "regular" },
          ["nw-nifite-ore"] = { frequency = "normal", size = "medium", richness = "regular" } ,
          ["grass"] = { frequency = "none", size = "none", richness = "none" },
          ["grass-medium"] = { frequency = "none", size = "none", richness = "none" },
          ["grass-dry"] = { frequency = "none", size = "none", richness = "none" },
          ["dirt"] = { frequency = "none", size = "none", richness = "none" },
          ["dirt-dark"] = { frequency = "none", size = "none", richness = "none" },
          ["sand"] = { frequency = "none", size = "none", richness = "none" },
          ["sand-dark"] = { frequency = "none", size = "none", richness = "none" },
          ["coal"] = { frequency = "none", size = "none", richness = "none" },
}
Makes the water disappear but nothing else. Extra odd because water hasn't been touched in that list.

The new wall/floor/ore tiles are spawning on both surfaces (which is fine for the moment although I'll have to make that stop in the end too).

~Any ideas on how it should be done?

Re: MapGenSettings for Surfaces

Posted: Sat Oct 01, 2016 2:33 pm
by Adil
Does your nidavellir-floor have associated noise layers? (Like trees and resources do.)
I believe changing entity's name to anidavellir-floor would give a hint on what's happening with water.
That is guesswork though.

Re: MapGenSettings for Surfaces

Posted: Sat Oct 01, 2016 11:23 pm
by jkeywo
I have noise layers for them all. Changing the name to anidavellir-floor just crashes the game on load, since the correct entity name doesn't exist.

The problem isn't that the nidavellir entities don't spawn, they do, on both surfaces, but I'm trying to stop everything else spawning on the surface I created.

Re: MapGenSettings for Surfaces

Posted: Sat Oct 01, 2016 11:50 pm
by Nexela
What does the whole surface creation code look like?

Re: MapGenSettings for Surfaces

Posted: Sun Oct 02, 2016 8:48 am
by jkeywo
OK, so the water and starting area settings are definitely getting used but the autoplace_controls aren't.

Code: Select all

local nauvis = game.surfaces["nauvis"];
   	local map_gen =
    {
      terrain_segmentation = "normal",
      water = "none",
      autoplace_controls = 
          { 
            ["nidavellir-floor"] = { frequency = "normal", size = "medium", richness = "regular" },
            ["nidavellir-wall"] = { frequency = "normal", size = "medium", richness = "regular" },
            ["nw-nifite-ore"] = { frequency = "normal", size = "medium", richness = "regular" } ,
            ["grass"] = { frequency = "none", size = "none", richness = "none" },
            ["grass-medium"] = { frequency = "none", size = "none", richness = "none" },
            ["grass-dry"] = { frequency = "none", size = "none", richness = "none" },
            ["dirt"] = { frequency = "none", size = "none", richness = "none" },
            ["dirt-dark"] = { frequency = "none", size = "none", richness = "none" },
            ["sand"] = { frequency = "none", size = "none", richness = "none" },
            ["sand-dark"] = { frequency = "none", size = "none", richness = "none" },
            ["coal"] = { frequency = "none", size = "none", richness = "none" }
          },
      seed = nauvis and nauvis.map_gen_settings.seed or math.round(math.random() * const.max_uint),
      shift = nauvis and nauvis.map_gen_settings.shift or nil,
      width = nauvis and nauvis.map_gen_settings.width or 0,
      height = nauvis and nauvis.map_gen_settings.height or 0,
      starting_area = "none",
      peaceful_mode = false
    }   
    
		nidavellir.surface = game.create_surface( "nidavellir", map_gen )

Re: MapGenSettings for Surfaces

Posted: Sun Oct 02, 2016 9:09 am
by jkeywo
It is picking up the changes to ores (the increased frequency of my own and the lack of coal) but it's not affecting the terrain tiles, maybe it's just supposed to?

I've tried adding "autoplace-control" for grass, trees, doodads, etc. but that doesn't make it work either.

Re: MapGenSettings for Surfaces

Posted: Sun Oct 02, 2016 9:38 am
by jkeywo
Partial success...

Terrain tiles didn't have a "control" value in their "autoplace" table, so by adding one and pointing it to something I could tell it not to bother spawning that autoplace-control.

Code: Select all

data:extend(
{
  {
    -- https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification
    type = "autoplace-control",
    name = "midgard",
    order = "b-e"
	}
})
-- for each "tile" "tree" and "decorative"
for _, _tile in pairs(data.raw.tile) do
  if _tile.autoplace ~= nil then
    _tile.autoplace.control = "midgard"
  end
end
for _, _tree in pairs(data.raw.tree) do
  if _tree.autoplace ~= nil then
    _tree.autoplace.control = "midgard"
  end
end
for _, _decorative in pairs(data.raw.decorative) do
  if _decorative.autoplace ~= nil then
    _decorative.autoplace.control = "midgard"
  end
end

Code: Select all

    local nauvis = game.surfaces["nauvis"];
   	local map_gen =
    {
      terrain_segmentation = "normal",
      water = "none",
      autoplace_controls = 
          { 
            ["nidavellir-floor"] = { frequency = "normal", size = "medium", richness = "regular" },
            ["nidavellir-wall"] = { frequency = "normal", size = "medium", richness = "regular" },
            ["nw-nifite-ore"] = { frequency = "normal", size = "medium", richness = "regular" } ,
            ["midgard"] = { frequency = "none", size = "none", richness = "none" },
            ["coal"] = { frequency = "none", size = "none", richness = "none" },
          },
      seed = nauvis and nauvis.map_gen_settings.seed or math.round(math.random() * const.max_uint),
      shift = nauvis and nauvis.map_gen_settings.shift or nil,
      width = nauvis and nauvis.map_gen_settings.width or 0,
      height = nauvis and nauvis.map_gen_settings.height or 0,
      starting_area = "none",
      peaceful_mode = true
    }   
    
		nidavellir.surface = game.create_surface( "nidavellir", map_gen )
Now I just need to stop my new stuff generating on nauvis