1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/modules/no_turrets.lua

29 lines
664 B
Lua
Raw Normal View History

2019-09-20 22:28:34 +02:00
local turret_types = {
2021-03-24 17:46:00 +02:00
['ammo-turret'] = true,
['artillery-turret'] = true,
['electric-turret'] = true,
['fluid-turret'] = true
2019-09-20 22:28:34 +02:00
}
local function destroy_turret(entity)
2021-03-24 17:46:00 +02:00
if not entity.valid then
return
end
if not turret_types[entity.type] then
return
end
entity.die()
2019-09-20 22:28:34 +02:00
end
local function on_built_entity(event)
2021-03-24 17:46:00 +02:00
destroy_turret(event.created_entity)
2019-09-20 22:28:34 +02:00
end
local function on_robot_built_entity(event)
2021-03-24 17:46:00 +02:00
destroy_turret(event.created_entity)
2019-09-20 22:28:34 +02:00
end
local event = require 'utils.event'
event.add(defines.events.on_built_entity, on_built_entity)
2021-03-24 17:46:00 +02:00
event.add(defines.events.on_robot_built_entity, on_robot_built_entity)