[Solved] MapGenSettings for Surfaces

Place to get help with not working mods / modding interface.
jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

[Solved] MapGenSettings for Surfaces

Post 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?
Last edited by jkeywo on Sun Oct 02, 2016 2:26 pm, edited 1 time in total.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: MapGenSettings for Surfaces

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

Re: MapGenSettings for Surfaces

Post 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.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: MapGenSettings for Surfaces

Post by Nexela »

What does the whole surface creation code look like?

jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

Re: MapGenSettings for Surfaces

Post 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 )

jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

Re: MapGenSettings for Surfaces

Post 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.

jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

Re: MapGenSettings for Surfaces

Post 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

Post Reply

Return to “Modding help”