Snippet that roughly demonstrates the problem:
Code: Select all
1. local surface = game.surfaces[1]
2. local map_settings = surface.map_gen_settings
3. local new_surface = game.create_surface("test", map_settings)
...
4. script.on_event(defines.events.on_surface_created, function(event)
5. if event.surface_index == 2 then
6. local map_settings = game.surfaces[2].map_gen_settings
7. -- map_settings is nil here and produces unrecoverable error
8. end
9. end)
map_settings from line 6 should be exactly the same as in line 2.
NOK behavior:
map_settings from line 6 is nil and causes unrecoverable error.