What I did
I'm creating a mod which calls LuaSurface.set_tiles in the script.on_init event handler. Some of the tiles I've instructed it to set to concrete are not set to concrete, and vice versa. I've only noticed the glitches at the outermost initially generated chunks, i.e. slightly further out than the initially charted chunks.In the real mod I use surface.get_chunks, but for the purposes of a minimal reproduction of the problem, hard coding 9 chunks radius produces the same result. The simplified mod (see included control.lua script) to confirm and demonstrate this behavior sets the entire surface to concrete, in the on_init handler.
control.lua:
Code: Select all
script.on_init(function()
for x = -9*32, 9*32 - 1 do
for y = -9*32, 9*32 - 1 do
game.surfaces[1].set_tiles({{name = 'concrete', position = {x, y}}}, false)
end
end
end
)
What did I expect
The edges of the concreted area should be smooth, with every tile in the initially generated chunks set to concrete, and every tile beyond that not concreted.What happened
The edges of the concreted area are "jagged". (See screenshot for map seed "1234". Other seeds also result in jagged edges at different positions around the concreted area.) Some of the tiles that should be concrete are not, and some of the tiles that should not be concrete are. The exact pattern of set and unset tiles is reproducible for a given map seed, using either Freeplay or Sandbox mode.I didn't see any error messages.
(Attachment: Screenshot of jagged edge of generated concrete, for map seed "1234". Tile grid shown for ease of reference.)
Variations tried
Passing an array of tiles rather than a single tile at a time to the set_tiles function had the same unexpected jagged result.Omitting the second parameter (correct_tiles) rather than setting it to false had the same unexpected jagged result.
Setting the tiles in a console script instead of in a mod's on_init handler did not produce any of the unexpected glitches.
Setting +/- 8 chunks in the mod produced some glitches, but much fewer.