Modding error

Place to get help with not working mods / modding interface.
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Modding error

Post by Vanra »

Greetings,

I've been playing this game since I bought it on Steam about a day or two ago and gotten completely addicted to it.

Seeing as I'm studying to become a programmer, I thought I'd give modding this game a try, yet I seem to have hit a wall.

For some reason, try to generate a new map or load a previous one, I get the same error:

Code: Select all

control.lua:14:LuaBootstrap doesn't contain key oninit.
I get that my error is on (or has something to do with) line 14, yet as far as I see and understand there is nothing wrong with it:

Code: Select all

script.oninit(function() OnInit() end)
Thank you for any help in advance.
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Modding error

Post by daniel34 »

The event is called script.on_init (notice the underline):
https://wiki.factorio.com/index.php?tit ... pt.on_init

In case you haven't seen it yet, there is also a folder named doc-html in the Factorio program folder that contains the documentation to the modding API.
quick links: log file | graphical issues | wiki
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Re: Modding error

Post by Vanra »

Thank you, I must've had C++ stuck in my mind somewhere, that did fix it.

And I missed the documentation completely. I'll be working my way though it now!

Thanks again!
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Re: Modding error

Post by Vanra »

Sadly enough I am getting a new error code now, one that I had to fix before, but this time it seems to be an issue somewhere else...

Code: Select all

Unknown key:"Error while running the on_init: .../control.lua:24:attempt to index global 'glob' (a nil value)"
Here is the code that should give the error.

Code: Select all

function OnInit()
	game.player.print("SmartSplitters: OnInit")
	if glob.sspl == nil then
		glob.sspl = {	splitSets = {},
						splitSetsToRemove = {},
						version = utils.currentVersion
					}
	else
		local total = 0
		for _, set in pairs(glob.sspl.splitSets) do
			total = total + #set.splitters
		end
		
		--game.player.print("Loaded " .. #glob.sspl.splitSets .. " splitter sets containing " .. total .. " splitters.")
	end
	if not glob.sspl.version then
		game.player.print("Migrating SmartSplitters from unversioned to version " .. utils.currentVersion)
		utils.migrations.versionless()
		game.player.print("Migration successful.")
	end
	if glob.sspl.version ~= utils.currentVersion then
		game.player.print("Migrating SmartSplitters from version " .. glob.sspl.version .. " to version " .. utils.currentVersion .. ".")
		utils.migrations[glob.sspl.version]()
		game.player.print("Migration successful.")
	end
end
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Modding error

Post by prg »

Version 0.12.0 changelog wrote:
  • Changed glob to global.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Re: Modding error

Post by Vanra »

Error 3:

I've tried looking it up and can't seem to find anything about it since most refer to the global version of this error.

Code: Select all

control.lua:228: attempt to index local '_Entity' (a nil value)
As for the code from line 227 to 229:

Code: Select all

function IsSmartSplitter(_Entity)
	return (_Entity.name == "Smart Splitter")
end
Thank you for your time.
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Modding error

Post by prg »

So whatever calls this function passes nil instead of an entity. Find out where that happens.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Re: Modding error

Post by Vanra »

The function gets called in 3 cases, when it is destroyed, mined or on build... I am guessing, since it happens when I put anything down it will have to do with the on build.

Code: Select all

function OnBuiltEntity(_Event)
local _Entity = _Event.createdentity
if IsSmartSplitter(_Entity) then
...
Which get called here:

Code: Select all

script.on_event(defines.events.on_built_entity, function(event) OnBuiltEntity(event) end)
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Modding error

Post by prg »

So it's a missing underscore again, this time in createdentity.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Vanra
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 03, 2016 8:32 pm
Contact:

Re: Modding error

Post by Vanra »

I'll go be ashamed in a corner right now... Sorry about that.
Post Reply

Return to “Modding help”