Lua help

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Twisted_Code
Long Handed Inserter
Long Handed Inserter
Posts: 83
Joined: Sat Jun 06, 2015 1:15 am
Contact:

Lua help

Post by Twisted_Code »

I'm looking for a bit of help understanding the game's Lua code structure. I tried using the wiki, but it doesn't seem to be very practical. For instance, I was trying to use the object detailed on the wiki at Lua/ItemStack, but I tried putting "/c game.player.print(ItemStack.help())", but this simply resulted in Lua throwing an error that was basically a complaint about trying to execute nil, the Lua equivalent of saying a function or method doesn't exist.
I am about as lost as one can be. This problem has me stumped. Could someone with significantly more experience explain what's going on and what I should've been trying?
Also could someone provide a link to a more comprehensive guide on Lua, because that could be part of my problem (Inexperience with Lua because, prior to this game, I've only ever used Lua with the Minecraft mod ComputerCraft)
How to report bugs effectively (archived version)because everyone should know this.
The game's tech tree, a visual reference guide.

Lee_newsum
Filter Inserter
Filter Inserter
Posts: 436
Joined: Wed Jan 15, 2014 9:41 am
Contact:

Re: Lua help

Post by Lee_newsum »

This is not the best part to ask you this help.
https://forums.factorio.com/forum/viewforum.php?f=25

(mod may mover it there)

ask/tel what you like to do, you get more help.
look at the mod there look at the code.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Lua help

Post by ssilk »

Moved from Off-Topic.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
semvoz
Inserter
Inserter
Posts: 30
Joined: Wed Jun 17, 2015 12:03 pm
Contact:

Re: Lua help

Post by semvoz »

Twisted_Code wrote:I tried putting "/c game.player.print(ItemStack.help())", but this simply resulted in Lua throwing an error that was basically a complaint about trying to execute nil, the Lua equivalent of saying a function or method doesn't exist.
First thing first, I do not think you can call the help() method on the ItemStack that way - ItemStack is nil, it is not referenced or pointing to anything.
You would need to get an 'instance' of the an itemstack first and then call the help() method on it. (but I might be wrong).

Second point, ItemStack looks to be a bad example here, because as far as I can see most of the time a SimpleItemStack is being manipulated, which is basically a simple table like so:

Code: Select all

stack = {
  name = 'iron-plate',
  count = 8
}
Nothing more, there might be a way to get an actual ItemStack but I would need to do some researches on a good example.

Post Reply

Return to “Modding help”