2018-08-28 14:31:23 +02:00
|
|
|
local Event = require 'utils.event'
|
2018-09-23 00:25:13 +02:00
|
|
|
local Game = require 'utils.game'
|
2018-08-28 14:31:23 +02:00
|
|
|
|
|
|
|
global.allowed_landfill_tiles = {}
|
|
|
|
|
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_built_tile,
|
|
|
|
function(event)
|
|
|
|
local item_name = event.item.name
|
|
|
|
if item_name ~= 'landfill' then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local allowed = global.allowed_landfill_tiles
|
|
|
|
|
|
|
|
local new_tiles = {}
|
|
|
|
for _, tile in ipairs(event.tiles) do
|
|
|
|
local name = tile.old_tile.name
|
|
|
|
if not allowed[name] then
|
|
|
|
tile.name = name
|
|
|
|
table.insert(new_tiles, tile)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local count = #new_tiles
|
|
|
|
if count == 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local surface = game.surfaces[event.surface_index]
|
|
|
|
surface.set_tiles(new_tiles)
|
|
|
|
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-08-28 14:31:23 +02:00
|
|
|
player.insert {name = item_name, count = count}
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
return function(allowed_set)
|
|
|
|
global.allowed_landfill_tiles = allowed_set
|
|
|
|
end
|