Fixture:setCategory and Fixture:setMask now accept a table of categories/masks (resolves issue #1178).

This commit is contained in:
Alex Szpakowski
2016-07-31 11:51:53 -03:00
parent 0a534d4751
commit 55cb2fad84
+15 -3
View File
@@ -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);
}