Page 1 of 1
LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:29 pm
by dingbat91
Hey there everyone nice to meet you!
I'm trying to make a small mod for friends and myself which adds a new inserter, it's been going well, but when I try and run the game with my mod I get the following:
Code: Select all
<mod folder>|data.lua:2:L:/factorio\data\core|lualib|dataloader.lua:10: bad argument #1 to 'ipairs' (table expected, got nil)
anybody know what's going on, just trying to figure out where I've gone wrong so I can fix it.
thanks for your help
-
Dingbat
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:32 pm
by kovarex
Hello, we will gladly help you, but you should provide the code you use in the mod. (Or you can just upload the work in progress mod)
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:41 pm
by FreeER
You pretty much have to read the error message backwards
, it's saying that there was a problem with calling the function ipairs on line 10 of the dataloader.lua file, because it was expecting to receive a table (that is data inside of these: '{}') as it's input.
Considering the error is in the dataloader file (a file that is never modified by modders because it takes the prototypes that a mod creates and places them the data.raw table which is then loaded into Factorio) I'd guess that one of your prototype files is not in
this format
Code: Select all
data:extend( --start of data:extend function call
{ --start of data:extend table
{ -- first entry
type="whatever"
--type specific information for this entry
}, -- end of first entry
-- other entries
{ -- last entry
type="whatever"
--type specific information for this entry
} -- end of last entry
} -- end of data.extend table
) -- end of data:extend function call.
but I can't be sure without actually seeing what you have. If that wasn't enough information to help you solve the issue I would highly suggest that you upload the mod as an attachment with your next post here so we can see it ourselves
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:41 pm
by dingbat91
Sure!
it's just an addition of a long arm smart inserter as requested by a friend.
Here is a rar containing the in-progress mod!
Thanks again!
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:44 pm
by dingbat91
I was really careful to make sure they were in that format, and I double checked.
the only one that isn't in a data:extend() table is my technology as that is just a modification to a base tech (Electronics) so I just call data.raw["technology"]["electronics"].effects =<blah>
FreeER wrote:You pretty much have to read the error message backwards
, it's saying that there was a problem with calling the function ipairs on line 10 of the dataloader.lua file, because it was expecting to receive a table (that is data inside of these: '{}') as it's input.
Considering the error is in the dataloader file (a file that is never modified by modders because it takes the prototypes that a mod creates and places them the data.raw table which is then loaded into Factorio) I'd guess that one of your prototype files is not in
this format
Code: Select all
data:extend( --start of data:extend function call
{ --start of data:extend table
{ -- first entry
type="whatever"
--type specific information for this entry
}, -- end of first entry
-- other entries
{ -- last entry
type="whatever"
--type specific information for this entry
} -- end of last entry
} -- end of data.extend table
) -- end of data:extend function call.
but I can't be sure without actually seeing what you have. If that wasn't enough information to help you solve the issue I would highly suggest that you upload the mod as an attachment with your next post here so we can see it ourselves
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:55 pm
by FreeER
ah. Found it. Within your items.lua file you call data
.extend instead of data
:extend. One
tiny little error
really easy to miss (that's why I copy/paste a lot lol)
Also, within the entities file the icon (right underneath the name) is "smart-inserter.png" instead of "long-smart-inserter.png" (so Factorio gives an error of "Sprite outside of "__SmartArm__/graphics/icons/smart-inserter.png" (at 32, 32, size of 0x0 of 0x0).")
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 8:56 pm
by dingbat91
ugh, I can't believe I missed that. darned eyes! thanks!
thanks for noting the icon issue as well!
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 9:00 pm
by FreeER
Happy to help, and I only spotted it because I was expecting an issue with the data formatting and didn't see one
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 9:22 pm
by slay_mithos
dingbat91 wrote:I was really careful to make sure they were in that format, and I double checked.
the only one that isn't in a data:extend() table is my technology as that is just a modification to a base tech (Electronics) so I just call data.raw["technology"]["electronics"].effects =<blah>
Oh, that is a newbie error too, your new effect should be inserted by
Code: Select all
table.insert(data.raw["technology"]["electronics"].effects, {type = "unlock-recipe",recipe = "long-smart-inserter",})
That way, you won't clash with other mods or future updates that would add other effects to that tech.
Re: LUA: Bad Argument
Posted: Mon Mar 24, 2014 9:25 pm
by dingbat91
thanks!