Page 1 of 1

[2.0.20] Map generator does not comply with width setting

Posted: Wed Nov 27, 2024 2:19 pm
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)

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

Posted: Wed Nov 27, 2024 2:27 pm
by plexpt
This code works perfectly fine on other planets, but not on nauvis.

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

Posted: Wed Nov 27, 2024 3:35 pm
by Rseding91
By the time on_init has run the default starter chunks for nauvis have already been generated.

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

Posted: Wed Nov 27, 2024 3:59 pm
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