1. The hidden light doesn't always get added when FARL places the pole[/list]
2. The hidden light doesn't always get removed when a bot deconstructs the pole
I'm registering for bot construction/deconstruction events:
Code: Select all
script.on_event(defines.events.on_robot_built_entity, BuiltEntity)
script.on_event(defines.events.on_robot_pre_mined , MinedEntity)
Code: Select all
function BuiltEntity(event)
if (event.created_entity.name == "lighted-small-electric-pole") or
(event.created_entity.name == "lighted-medium-electric-pole") or
(event.created_entity.name == "lighted-big-electric-pole") or
(event.created_entity.name == "lighted-substation")
then
local e = event.created_entity
local s = e.surface
local X = e.position.x
local Y = e.position.y
local l = s.create_entity{name = "hidden-small-lamp", position = {X,Y}, force= game.forces.neutral}
l.destructible = false
end
end
Code: Select all
function MinedEntity(event)
if (event.entity.name == "lighted-small-electric-pole") or
(event.entity.name == "lighted-medium-electric-pole") or
(event.entity.name == "lighted-big-electric-pole") or
(event.entity.name == "lighted-substation")
then
local b = event.entity
local X = b.position.x
local Y = b.position.y
lamp = b.surface.find_entity("hidden-small-lamp",{X, Y})
if lamp ~= nil then
lamp.destroy() end
end
end
Thanks!