Page 1 of 1

"..." argument returning strange things

Posted: Sun Dec 22, 2013 12:42 am
by TheConfuZzledDude
I'm using the "..." in my function and then adding it's contents to a table in my object (hump.class btw). When I iterate through with pairs it just gives me strange things:
1 Documents\Trision\Trision.love
-2 C:\Program Files\LOVE\love.exe
-1 embedded boot.lua

instead of a list of numbers. Why is this happening?

Re: "..." argument returning strange things

Posted: Sun Dec 22, 2013 2:05 am
by slime
The 'arg' variable is a global table holding the command-line arguments given to LÖVE, it doesn't contain the vararg list in a function. Unfortunately the online edition of the Programming in Lua book is a very old version written for an old version of Lua, so it contains the wrong information in this case.

You can do something like this instead:

Code: Select all

init = function(self, ...)
  self.test = {...}
end