Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Last active March 24, 2023 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zbizu/b8ae694995d3753f2fc1aa1ecc27ddb5 to your computer and use it in GitHub Desktop.
Save Zbizu/b8ae694995d3753f2fc1aa1ecc27ddb5 to your computer and use it in GitHub Desktop.
Lua get a vector of integers for C++
void LuaScriptInterface::getIntVector(lua_State* L, int32_t arg, std::vector<uint32_t>& vec)
{
lua_pushnil(L);
while (lua_next(L, arg) != 0) {
if (lua_isnumber(L, -1)) {
vec.push_back(lua_tointeger(L, -1));
}
lua_pop(L, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment