Page 1 of 1

Missing info for LuaSurface::get_chunks()

Posted: Sun Oct 05, 2025 8:40 am
by Pi-C
The description of LuaTerritory::get_chunks() contains the following sentence:
Chunks may or may not be generated; use LuaSurface::is_chunk_generated to check a chunk's state before accessing it.
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:

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)

Re: Missing info for LuaSurface::get_chunks()

Posted: Mon Oct 06, 2025 12:07 pm
by Bilka
Thanks for the note and the script to reproduce. I've updated the description for the next doc release.