This sentence is missing from the description of LuaSurface::get_chunks(). Without it, people may expect that LuaSurface::get_chunks() will only return created chunks. However, it may also get you ungenerated chunks! Run the following from the chat console for a demonstration, preferably in a newly started game:Chunks may or may not be generated; use LuaSurface::is_chunk_generated to check a chunk's state before accessing it.
Code: Select all
/c script.on_nth_tick(600, function(event)
local surface = game.surfaces[1]
local pos
for chunk in surface.get_chunks() do
pos = {chunk.x, chunk.y}
game.print(string.format("Chunk %s is generated: %s",
serpent.line(pos), surface.is_chunk_generated(pos)))
end
end)

