Defines missing / can't access defines elements?

Place to get help with not working mods / modding interface.
Bearnaise
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Jul 16, 2015 12:50 am
Contact:

Defines missing / can't access defines elements?

Post 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?
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

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

Post by prg »

Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

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

Post 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.
Bearnaise
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Jul 16, 2015 12:50 am
Contact:

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

Post by Bearnaise »

Ooh... Google was giving me the 12.35 defines list. No wonder I couldn't find it :/ Thanks a lot!
Bearnaise
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Jul 16, 2015 12:50 am
Contact:

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

Post 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!
Post Reply

Return to “Modding help”