Page 1 of 1

0.8.0 - setMask/getMask API weirdness

Posted: Mon May 21, 2012 4:30 am
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.

Re: 0.8.0 - setMask/getMask API weirdness

Posted: Mon May 21, 2012 6:06 am
by Boolsheet
Lua has the unpack function for that.

Re: 0.8.0 - setMask/getMask API weirdness

Posted: Mon May 21, 2012 7:09 am
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?

Re: 0.8.0 - setMask/getMask API weirdness

Posted: Mon May 21, 2012 7:25 am
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.