From efebf9c003d35e424dea949c34a911d47ccf3104 Mon Sep 17 00:00:00 2001 From: MewMew Date: Wed, 4 Dec 2019 06:18:12 +0100 Subject: [PATCH] new module --- modules/no_solar.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 modules/no_solar.lua diff --git a/modules/no_solar.lua b/modules/no_solar.lua new file mode 100644 index 00000000..b910d79c --- /dev/null +++ b/modules/no_solar.lua @@ -0,0 +1,23 @@ +local function deny_building(event) + local entity = event.created_entity + if not entity.valid then return end + if entity.type ~= "solar-panel" then return end + local surface = entity.surface + local name = entity.name + local position = {entity.position.x, entity.position.y} + entity.destroy() + surface.create_entity({name = "flying-text", position = position, text = name .. " can not be placed.", color = {r=0.77, g=0.00, b=0.00}}) + surface.spill_item_stack(position,{name = name, count = 1}, true) +end + +local function on_built_entity(event) + deny_building(event) +end + +local function on_robot_built_entity(event) + deny_building(event) +end + +local event = require 'utils.event' +event.add(defines.events.on_built_entity, on_built_entity) +event.add(defines.events.on_robot_built_entity, on_robot_built_entity) \ No newline at end of file