LUA: Bad Argument

Place to get help with not working mods / modding interface.
Post Reply
dingbat91
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Mar 24, 2014 8:22 pm
Contact:

LUA: Bad Argument

Post 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

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: LUA: Bad Argument

Post 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)

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: LUA: Bad Argument

Post 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 :)

dingbat91
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Mar 24, 2014 8:22 pm
Contact:

Re: LUA: Bad Argument

Post 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!
Attachments
SmartArm.rar
(26.94 KiB) Downloaded 169 times

dingbat91
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Mar 24, 2014 8:22 pm
Contact:

Re: LUA: Bad Argument

Post 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 :)

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: LUA: Bad Argument

Post by FreeER »

ah. Found it. Within your items.lua file you call data.extend instead of data:extend. One tiny little error :lol: 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).")

dingbat91
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Mar 24, 2014 8:22 pm
Contact:

Re: LUA: Bad Argument

Post by dingbat91 »

ugh, I can't believe I missed that. darned eyes! thanks!

thanks for noting the icon issue as well!

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: LUA: Bad Argument

Post 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 :D

slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: LUA: Bad Argument

Post 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.

dingbat91
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Mar 24, 2014 8:22 pm
Contact:

Re: LUA: Bad Argument

Post by dingbat91 »

thanks!

Post Reply

Return to “Modding help”