Page 1 of 1

What does LuaSurface::set_chunk_generated_status so?

Posted: Wed May 17, 2017 3:28 pm
by sparr
What does this method actually DO? Particularly with all the various status values.

http://lua-api.factorio.com/latest/LuaS ... ted_status

set_chunk_generated_status(position, status)
Set generated status of a chunk. Useful when copying chunks.

Parameters
position :: Position: The chunk's position.
status :: defines.chunk_generated_status: The chunk's new status.


chunk_generated_status
defines.chunk_generated_status.nothing
defines.chunk_generated_status.custom_tiles
defines.chunk_generated_status.basic_tiles
defines.chunk_generated_status.corrected_tiles
defines.chunk_generated_status.tiles
defines.chunk_generated_status.entities

Re: What does LuaSurface::set_chunk_generated_status so?

Posted: Fri May 19, 2017 7:56 pm
by Exasperation
I've messed around with this a little, so while I don't know everything about it I do know some. From what I recall, the defines are multiples of 10, and when the vanilla chunk generation goes to perform a piece of chunk generation it will assume everything up to the currently set status has already been completed. In particular, if you set it to defines.chunk_generated_status.entities, it will cause is_chunk_generated() to return true for that chunk. That means that if you have a chunk that may or may not have generated and you want to completely override the vanilla behavior you can start by setting the status to defines.chunk_generated_status.entities to keep any pending vanilla generation from overwriting your work (basically, telling the terrain generator it already finished with the chunk).

Re: What does LuaSurface::set_chunk_generated_status so?

Posted: Fri May 19, 2017 8:00 pm
by Klonan
sparr wrote:What does this method actually DO? Particularly with all the various status values.

http://lua-api.factorio.com/latest/LuaS ... ted_status

set_chunk_generated_status(position, status)
Set generated status of a chunk. Useful when copying chunks.

Parameters
position :: Position: The chunk's position.
status :: defines.chunk_generated_status: The chunk's new status.


chunk_generated_status
defines.chunk_generated_status.nothing
defines.chunk_generated_status.custom_tiles
defines.chunk_generated_status.basic_tiles
defines.chunk_generated_status.corrected_tiles
defines.chunk_generated_status.tiles
defines.chunk_generated_status.entities
It sets the level of generation in the chunk,

So for instance, i copy a chunk to somewhere it is currently not generated, the game will not know that this chunk should not be overwritten, so the games map generator will generate over the top of it

By setting the chunk generated status, it tells the map generator what it should do with the chunk, if its at entities, then it will not do anything to the chunk