mirror of
https://github.com/love2d/love.git
synced 2026-08-13 17:10:54 +02:00
Fixture:setCategory and Fixture:setMask now accept a table of categories/masks (resolves issue #1178).
This commit is contained in:
@@ -193,16 +193,28 @@ int Fixture::getMask(lua_State *L)
|
||||
uint16 Fixture::getBits(lua_State *L)
|
||||
{
|
||||
// Get number of args.
|
||||
int argc = lua_gettop(L);
|
||||
bool istable = lua_istable(L, 1);
|
||||
int argc = istable ? (int) luax_objlen(L, 1) : lua_gettop(L);
|
||||
|
||||
// The new bitset.
|
||||
std::bitset<16> b;
|
||||
|
||||
for (int i = 1; i<=argc; i++)
|
||||
for (int i = 1; i <= argc; i++)
|
||||
{
|
||||
size_t bpos = (size_t)(lua_tointeger(L, i)-1);
|
||||
size_t bpos = 0;
|
||||
|
||||
if (istable)
|
||||
{
|
||||
lua_rawgeti(L, 1, i);
|
||||
bpos = (size_t) (lua_tointeger(L, -1) - 1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
else
|
||||
bpos = (size_t) (lua_tointeger(L, i) - 1);
|
||||
|
||||
if (bpos >= 16)
|
||||
luaL_error(L, "Values must be in range 1-16.");
|
||||
|
||||
b.set(bpos, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user