Add non-blocking request_to_regenerate methods

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
InappropriatePenguin
Inserter
Inserter
Posts: 29
Joined: Mon Sep 13, 2021 6:53 pm
Contact:

Add non-blocking request_to_regenerate methods

Post by InappropriatePenguin »

The most straightforward way to regenerate entities and decoratives after tile replacement is to use LuaSurface :: regenerate_entity and LuaSurface :: regenerate_decorative. The problem with both of these functions is that they block further script execution until they are completed.

While those functions appear to be capable of using multiple threads when given an array of chunks to process, it's cumbersome to do so if the tile replacement is being done inside an on_chunk_generated handler. When those functions are called on single chunks, the multithreaded capability of those functions is presumably wasted.

My proposal is to add the following:
  • LuaSurface :: request_to_regenerate_entity(entities, chunks)
  • LuaSurface :: request_to_regenerate_decorative(decoratives, chunks)
The parameters would match the existing non-request versions of those functions. The intent would be for the map generator to handle the requests when it chooses, similar to how it handles chunk generation requests.

Post Reply

Return to “Modding interface requests”