|
@@ -193,16 +193,28 @@ int Fixture::getMask(lua_State *L)
|
|
uint16 Fixture::getBits(lua_State *L)
|
|
uint16 Fixture::getBits(lua_State *L)
|
|
{
|
|
{
|
|
// Get number of args.
|
|
// 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.
|
|
// The new bitset.
|
|
std::bitset<16> b;
|
|
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)
|
|
if (bpos >= 16)
|
|
luaL_error(L, "Values must be in range 1-16.");
|
|
luaL_error(L, "Values must be in range 1-16.");
|
|
|
|
+
|
|
b.set(bpos, true);
|
|
b.set(bpos, true);
|
|
}
|
|
}
|
|
|
|
|