Code: Select all
require "defines"
script.on_event(defines.events.on_built_entity, function(event)
local built = event.created_entity
local poles = {}
if not built == "electric-pole" then return
elseif built.name == "big-electric-pole" then
local localArea = {{built.position["x"]-2, built.position["y"]-2}, {built.position["x"]+2, built.position["y"]+2}}
local poles = built.surface.find_entities_filtered{area = localArea, name= "big-electric-pole"}
if next(poles)~=nil then
for i in pairs(poles) do
built.connect_neighbour{wire = defines.circuit_connector.green, target_entity = poles[i]}
end
end
return
elseif event.created_entity.name == "medium-electric-pole" then return
elseif event.created_entity.name == "small-electric-pole" then return
elseif event.created_entity.name == "substation" then return
end
end)
When I remove that line, the event handler works fine (even though it requires defines?), and my save will load. But now if I try to place a big electric pole down, it says 'circuit_connector' is a nil value. In the 13.0 changelog, they said the define "circuitconnector" was changed to "circuit_connector." So why am I getting a nil value?