1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-20 03:29:47 +02:00
ComfyFactorio/modules/no_deconstruction_of_neutral_entities.lua

17 lines
527 B
Lua
Raw Normal View History

2019-12-22 17:16:26 +01:00
local blacklist = {
["cliff"] = true,
["item-entity"] = true,
}
2019-08-06 03:04:35 +02:00
2019-12-22 17:16:26 +01:00
local function on_marked_for_deconstruction(event)
local entity = event.entity
if not entity.valid then return end
2019-12-22 17:16:26 +01:00
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 17:16:26 +01:00
local Event = require 'utils.event'
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)