"..." argument returning strange things

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
TheConfuZzledDude
Prole
Posts: 21
Joined: Fri Nov 02, 2012 10:23 pm

"..." argument returning strange things

Post 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?
Attachments
Trision.love
(13.83 KiB) Downloaded 96 times
User avatar
slime
Solid Snayke
Posts: 3157
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: "..." argument returning strange things

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

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests