How to generate surface from planet but with custom map-gen

Place to get help with not working mods / modding interface.
anakhon
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Apr 09, 2025 6:23 pm
Contact:

How to generate surface from planet but with custom map-gen

Post by anakhon »

Hello,

I'm trying to generate custom surfaces related to planets, to be able to randomize ore/enemy presence, etc, of the surface.
To do this, I basically create a surface using the planet mapgen with changes, then associate the surface with the planet (previous surface is deleted).
The goal is to keep the lightning, pressure, magnetism, pollution type, etc depending on the planet, while being able to randomize the map-gen for ore and ennemies

Code: Select all

--- example
local mapgen = game.planets['vulcanus'].prototype.map_gen_settings
mapgen.seed=12345
local surface = game.create_surface('[img=space-location.vulcanus] vulcanus-XX', mapgen)
game.planets['vulcanus'].associate_surface(surface)
Unfortunately, for Aquilo, since the planet has "entities_require_heating", the associate_surface method doesn't work.
I tried to generate the surface using LuaPlanet.generate_surface(), then changing the mapgen and deleting chunk to have something changed, but i didn't seem to work...

Code: Select all

--- this doesn't work ?
local surface = game.planets['aquilo'].create_surface()
surface.map_gen_settings.autoplace_controls.aquilo_crude_oil.frequency=10
surface.map_gen_settings.autoplace_controls.lithium_brine.frequency=10
surface.map_gen_settings.autoplace_controls.fluorine_vent.frequency=10
surface.map_gen_settings.seed=66666

for chunk in surface.get_chunks() do
    surface.delete_chunk({x = chunk.x, y = chunk.y})
end
Should I also use "regenerate_entity()" and "regenerate_decorative()" ? But this wouldn't add the missing tiles?

Maybe i'm not doing it the right way ?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3745
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to generate surface from planet but with custom map-gen

Post by DaveMcW »

Can you do it in data.lua?

Code: Select all

data.raw['planet']['aquilo'].map_gen_settings.autoplace_controls.aquilo_crude_oil.frequency = 10
data.raw['planet']['aquilo'].map_gen_settings.autoplace_controls.lithium_brine.frequency = 10
data.raw['planet']['aquilo'].map_gen_settings.autoplace_controls.fluorine_vent.frequency = 10
anakhon
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Apr 09, 2025 6:23 pm
Contact:

Re: How to generate surface from planet but with custom map-gen

Post by anakhon »

I could.

Doing it in the prototypes would be my last solution if I don't find a way to do it during runtime.
I wanted to have multiple aquilo profile, like "lots of resources, scarces, some missing, etc"). (mostly random generate with min/max, so each time it's "random").
Post Reply

Return to “Modding help”