[2.0.20] Map generator does not comply with width setting

Place to get help with not working mods / modding interface.
plexpt
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Mon Feb 07, 2022 2:32 am
Contact:

[2.0.20] Map generator does not comply with width setting

Post by plexpt »

Issue Description:

After modifying the map generation settings using the on_init event, the game generates new chunks with the size of 320x320 instead of the expected custom size (e.g., 9x9).

Steps to Reproduce:

Call the init_surface_settings function within the on_init event to modify the map generation settings, including chunk width and height.
Start a new game and observe the generated chunk size.
Expected Result:

The chunks should be generated with the custom size specified in the settings, e.g., width=9.

Actual Result:

The chunks are generated with the size of 320x320.



code

Code: Select all

local function init_surface_settings(surface)
    
    local mgs = surface.map_gen_settings
    mgs.width = 9
 
    surface.map_gen_settings = mgs
end

script.on_init(function()
 
    if game.surfaces then
        for _, surface in pairs(game.surfaces) do
            init_surface_settings(surface)
        end
    end
end)

script.on_event(defines.events.on_surface_created, function(event)
    local surface = game.get_surface(event.surface_index)
    if surface then
        log("Detected new surface: " .. surface.name)
        init_surface_settings(surface)
    end
end)
plexpt
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Mon Feb 07, 2022 2:32 am
Contact:

Re: [2.0.20] Map generator does not comply with width setting

Post by plexpt »

This code works perfectly fine on other planets, but not on nauvis.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14798
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.20] Map generator does not comply with width setting

Post by Rseding91 »

By the time on_init has run the default starter chunks for nauvis have already been generated.
If you want to get ahold of me I'm almost always on Discord.
plexpt
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Mon Feb 07, 2022 2:32 am
Contact:

Re: [2.0.20] Map generator does not comply with width setting

Post by plexpt »

Rseding91 wrote: Wed Nov 27, 2024 3:35 pm By the time on_init has run the default starter chunks for nauvis have already been generated.
so how to do that
Post Reply

Return to “Modding help”