0.8.0 - setMask/getMask API weirdness

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
User avatar
icefox
Prole
Posts: 5
Joined: Mon Apr 30, 2012 2:25 am

0.8.0 - setMask/getMask API weirdness

Post by icefox »

Okay, so I don't yet know all the ins and outs of Lua, but I have a problem with Fixture:setMask and getMask... Essentially I want to save the collision mask of an object, and restore it later, but I can't seem to find a good way of doing it.

I can store the collision mask easily thus, no matter how large it is:

Code: Select all

mask = {somefixture:getMask()}
But then I appear to have no good way of shoving it back into setMask(). Ideally I'd want to do something like this:

Code: Select all

somefixture:setMask(mask)
where "mask" is the table saved in the previous code. But that just passes a table to the function as the first argument, which doesn't work. Is there some way of expanding that table out into multiple arguments... somehow? I've looked through the Lua docs and and can't see anything like that. Is there a better way of doing this? If not, can I beg that the next version of LOVE takes this into account when deciding how getMask and setMask will work?

Thanks in advance.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: 0.8.0 - setMask/getMask API weirdness

Post by Boolsheet »

Lua has the unpack function for that.
Shallow indentations.
User avatar
icefox
Prole
Posts: 5
Joined: Mon Apr 30, 2012 2:25 am

Re: 0.8.0 - setMask/getMask API weirdness

Post by icefox »

Yeah, I found that about ten minutes after I made the post. :crazy: It still seems like a weird API decision though. Unless you always know exactly how many categories you're going to have, you're going to want it to be in a table anyway so you can iterate through it and such.

So as long as I'm here, does LOVE always use Lua 5.1, or can it be built with Lua 5.2?
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: 0.8.0 - setMask/getMask API weirdness

Post by Boolsheet »

icefox wrote:It still seems like a weird API decision though.
Yeah. It's a bit tricky to map the Box2D API to Lua. I'm sure some refinements will be made sooner or later.
icefox wrote:So as long as I'm here, does LOVE always use Lua 5.1, or can it be built with Lua 5.2?
The current code does not compile with Lua 5.2. Some minor modifications are necessary to make it build.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests