might be a bug.
Placing 2 square blocks of water next to each other is impossible. The terrain reforms in a strange way.
terrain is acting weard
Re: terrain is acting weard
Code: Select all
script.on_event(defines.events.on_player_built_tile, function(event)
-- only when square size is 1x1
if #event.positions == 1 then
local x = event.positions[1].x
local y = event.positions[1].y
local dig_positions2 = {}
table.insert(dig_positions2, {name = "water", position = {x+1.5, y+1.5}})
table.insert(dig_positions2, {name = "water", position = {x+1.5, y-1.5}})
table.insert(dig_positions2, {name = "water", position = {x-1.5, y+1.5}})
table.insert(dig_positions2, {name = "water", position = {x-1.5, y-1.5}})
table.insert(dig_positions2, {name = "water", position = {x+1.5, y+0.5}})
table.insert(dig_positions2, {name = "water", position = {x+1.5, y-0.5}})
table.insert(dig_positions2, {name = "water", position = {x+0.5, y+1.5}})
table.insert(dig_positions2, {name = "water", position = {x+0.5, y-1.5}})
table.insert(dig_positions2, {name = "water", position = {x-0.5, y+1.5}})
table.insert(dig_positions2, {name = "water", position = {x-0.5, y-1.5}})
table.insert(dig_positions2, {name = "water", position = {x-1.5, y+0.5}})
table.insert(dig_positions2, {name = "water", position = {x-1.5, y-0.5}})
table.insert(dig_positions2, {name = "water", position = {x+1.5, y }})
table.insert(dig_positions2, {name = "water", position = {x-1.5, y }})
table.insert(dig_positions2, {name = "water", position = {x , y+1.5}})
table.insert(dig_positions2, {name = "water", position = {x , y-1.5}})
table.insert(dig_positions2, {name = "water", position = {x+0.5, y+0.5}})
table.insert(dig_positions2, {name = "water", position = {x+0.5, y-0.5}})
table.insert(dig_positions2, {name = "water", position = {x-0.5, y+0.5}})
table.insert(dig_positions2, {name = "water", position = {x-0.5, y-0.5}})
table.insert(dig_positions2, {name = "water", position = {x , y+0.5}})
table.insert(dig_positions2, {name = "water", position = {x+0.5, y }})
table.insert(dig_positions2, {name = "water", position = {x , y-0.5}})
table.insert(dig_positions2, {name = "water", position = {x-0.5, y }})
table.insert(dig_positions2, {name = "water", position = {x , y }})
-- increase the size to a 5x5
local dig_positions = {}
table.insert(dig_positions, {name = "water", position = {x+2, y+2}})
table.insert(dig_positions, {name = "water", position = {x+2, y-2}})
table.insert(dig_positions, {name = "water", position = {x-2, y+2}})
table.insert(dig_positions, {name = "water", position = {x-2, y-2}})
table.insert(dig_positions, {name = "water", position = {x+2, y+1}})
table.insert(dig_positions, {name = "water", position = {x+2, y-1}})
table.insert(dig_positions, {name = "water", position = {x+1, y+2}})
table.insert(dig_positions, {name = "water", position = {x+1, y-2}})
table.insert(dig_positions, {name = "water", position = {x-1, y+2}})
table.insert(dig_positions, {name = "water", position = {x-1, y-2}})
table.insert(dig_positions, {name = "water", position = {x-2, y+1}})
table.insert(dig_positions, {name = "water", position = {x-2, y-1}})
table.insert(dig_positions, {name = "water", position = {x+2, y }})
table.insert(dig_positions, {name = "water", position = {x-2, y }})
table.insert(dig_positions, {name = "water", position = {x , y+2}})
table.insert(dig_positions, {name = "water", position = {x , y-2}})
table.insert(dig_positions, {name = "water", position = {x+1, y+1}})
table.insert(dig_positions, {name = "water", position = {x+1, y-1}})
table.insert(dig_positions, {name = "water", position = {x-1, y+1}})
table.insert(dig_positions, {name = "water", position = {x-1, y-1}})
table.insert(dig_positions, {name = "water", position = {x , y+1}})
table.insert(dig_positions, {name = "water", position = {x+1, y }})
table.insert(dig_positions, {name = "water", position = {x , y-1}})
table.insert(dig_positions, {name = "water", position = {x-1, y }})
table.insert(dig_positions, {name = "water", position = {x , y }})
for index, record in pairs(dig_positions) do
if not game.surfaces[1].can_place_entity({name="steel-chest", position=record.position}) then
return nil
end
end
for index, record in pairs(dig_positions2) do
if not game.surfaces[1].can_place_entity({name="steel-chest", position=record.position}) then
return nil
end
end
game.surfaces[1].set_tiles(dig_positions2)
game.surfaces[1].set_tiles(dig_positions)
game.surfaces[1].set_tiles(dig_positions2)
-- slSaysAll("I dug a hole @ " .. x .. " x " .. y)
end
end)
Re: terrain is acting weard
Thats just the tile correction, set the second parameter of 'set_tiles' to false if you don't want them to correct
Re: terrain is acting weard
Thank you.
Was not my solution but it gave me the correct idea.
5x5 was too small it works for a 7x7 grid
Was not my solution but it gave me the correct idea.
5x5 was too small it works for a 7x7 grid

