Code: Select all
function plot_create_moat(event, plot_number)
DebugPrint("Creating moat for plot " .. plot_number )
local player = game.players[event.element.player_index]
local surface = player.surface
local waterTiles = {}
local watertType = "water"
local x = 0
local y = 0
local distance = 0
distance = global.plot_table[plot_number]["inner_corners"]["top_right"][1] - global.plot_table[plot_number]["inner_corners"]["top_left"][1]
DebugPrint("distance " .. distance)
y = global.plot_table[plot_number]["inner_corners"][2]
for i=0,distance,1 do
table.insert(waterTiles, {name = watertType, position={x+i,y}})
end
DebugPrint(table_to_string(event))
surface.set_tiles(waterTiles)
end
I can use this code with the on_chunk_generated, but can't get it to work with the click.bad arguement #-1 to 'set_tiles' (number expected, got table)
Any ideas?