2019-12-22 18:16:26 +02:00
|
|
|
local blacklist = {
|
2021-03-24 17:46:00 +02:00
|
|
|
['cliff'] = true,
|
|
|
|
['item-entity'] = true
|
2019-12-22 18:16:26 +02:00
|
|
|
}
|
2019-08-06 03:04:35 +02:00
|
|
|
|
2019-12-22 18:16:26 +02:00
|
|
|
local function on_marked_for_deconstruction(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
local entity = event.entity
|
|
|
|
if not entity.valid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if not event.player_index then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if entity.force.name ~= 'neutral' then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if blacklist[entity.type] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
entity.cancel_deconstruction(game.players[event.player_index].force.name)
|
2019-08-06 03:04:35 +02:00
|
|
|
end
|
2019-12-22 18:16:26 +02:00
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
local Event = require 'utils.event'
|
2020-03-13 20:26:43 +02:00
|
|
|
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|