Missing info for LuaSurface::get_chunks()

Pi-C
Smart Inserter
Smart Inserter
Posts: 1788
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Missing info for LuaSurface::get_chunks()

Post 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)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Bilka
Factorio Staff
Factorio Staff
Posts: 3672
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Missing info for LuaSurface::get_chunks()

Post by Bilka »

Thanks for the note and the script to reproduce. I've updated the description for the next doc release.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved Requests”