[1.1.57] Factorio API - chunk area overlap
Posted: Mon May 09, 2022 10:00 pm
In Factorio API
chunk.area is overlapping with another chunk area.
Illustration
Execute following code in Map Editor in
chunk.area is overlapping with another chunk area.
Illustration
Execute following code in Map Editor in
Code: Select all
local surface = game.surfaces.nauvis
local newTiles = {}
for chunk in surface.get_chunks() do
if surface.is_chunk_generated(chunk) then
if (chunk.x == -6 and chunk.y == -6) then
game.print(chunk.area.left_top.x.." "..chunk.area.left_top.y)
game.print(chunk.area.right_bottom.x.." "..chunk.area.right_bottom.y)
for x=chunk.area.left_top.x,chunk.area.right_bottom.x do
for y=chunk.area.left_top.y,chunk.area.right_bottom.y do
table.insert(newTiles, {name="red-refined-concrete", position={x=x,y=y}})
end
end
end
end
end
surface.set_tiles(newTiles)
--- Tiles touched outside of a chunk
Code: Select all
local surface = game.surfaces.nauvis
for chunk in surface.get_chunks() do
if surface.is_chunk_generated(chunk) then
if (chunk.x == -1 and chunk.y == -1) then
game.print("ch1 "..chunk.area.left_top.x.." "..chunk.area.left_top.y)
end
if (chunk.x == -2 and chunk.y == -2) then
game.print("ch2 "..chunk.area.right_bottom.x.." "..chunk.area.right_bottom.y)
end
end
end