int MeshBinder::setIndices(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); if (lua_type(L, 2) == LUA_TTABLE) { int n = lua_objlen(L, 2); for (int k = 0; k < n/2; ++k) { lua_rawgeti(L, 2, k * 2 + 1); int i = luaL_checkinteger(L, -1) - 1; lua_pop(L, 1); lua_rawgeti(L, 2, k * 2 + 2); int index = luaL_checknumber(L, -1) - 1; lua_pop(L, 1); mesh->setIndex(i, index); } } else { int n = lua_gettop(L) - 1; for (int k = 0; k < n/2; ++k) { int i = luaL_checkinteger(L, k * 2 + 2) - 1; int index = luaL_checknumber(L, k * 2 + 3) - 1; mesh->setIndex(i, index); } } return 0; }
int MeshBinder::setIndex(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; int index = luaL_checkinteger(L, 3) - 1; mesh->setIndex(i, index); return 0; }