Page 1 of 1

Defines missing / can't access defines elements?

Posted: Mon Jul 11, 2016 12:04 am
by Bearnaise
I have the following code:

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 run this in game it tells me which line "require 'defines'" is on and says "module defines not found; no such file"

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?

Re: Defines missing / can't access defines elements?

Posted: Mon Jul 11, 2016 12:44 am
by prg

Re: Defines missing / can't access defines elements?

Posted: Mon Jul 11, 2016 1:45 am
by Nexela
When I remove that line, the event handler works fine (even though it requires defines?),
As of .13 you don't have to require defines anymore.

Re: Defines missing / can't access defines elements?

Posted: Mon Jul 11, 2016 4:41 am
by Bearnaise
Ooh... Google was giving me the 12.35 defines list. No wonder I couldn't find it :/ Thanks a lot!

Re: Defines missing / can't access defines elements?

Posted: Mon Jul 11, 2016 5:02 am
by Bearnaise
Nexela wrote:
When I remove that line, the event handler works fine (even though it requires defines?),
As of .13 you don't have to require defines anymore.
I thought that was the case, just missed it in the changelog... Thanks!