allow vectors to be read from indices other than 1

develop
Myk Taylor 2023-03-02 19:32:10 -08:00
parent f9924d9090
commit 028bbca07b
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

@ -121,10 +121,10 @@ void DFHack::Lua::Push(lua_State *state, const df::coord2d &pos)
lua_setfield(state, -2, "y");
}
void DFHack::Lua::GetVector(lua_State *state, std::vector<std::string> &pvec)
void DFHack::Lua::GetVector(lua_State *state, std::vector<std::string> &pvec, int idx)
{
lua_pushnil(state); // first key
while (lua_next(state, 1) != 0)
while (lua_next(state, idx) != 0)
{
pvec.push_back(lua_tostring(state, -1));
lua_pop(state, 1); // remove value, leave key

@ -359,7 +359,7 @@ namespace DFHack {namespace Lua {
}
}
DFHACK_EXPORT void GetVector(lua_State *state, std::vector<std::string> &pvec);
DFHACK_EXPORT void GetVector(lua_State *state, std::vector<std::string> &pvec, int idx = 1);
DFHACK_EXPORT int PushPosXYZ(lua_State *state, const df::coord &pos);
DFHACK_EXPORT int PushPosXY(lua_State *state, const df::coord2d &pos);