1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add NodeResolver and clean up node name -> content ID resolution system

This commit is contained in:
kwolekr 2014-10-08 15:28:14 -04:00
parent b49e5cfc70
commit d274cbfce6
11 changed files with 445 additions and 342 deletions

View file

@ -227,6 +227,25 @@ std::vector<aabb3f> read_aabb3f_vector(lua_State *L, int index, f32 scale)
return boxes;
}
bool read_stringlist(lua_State *L, int index, std::vector<const char *> &result)
{
if (index < 0)
index = lua_gettop(L) + 1 + index;
if (lua_istable(L, index)) {
lua_pushnil(L);
while (lua_next(L, index)) {
result.push_back(lua_tostring(L, -1));
lua_pop(L, 1);
}
} else if (lua_isstring(L, index)) {
result.push_back(lua_tostring(L, index));
} else {
return false;
}
return true;
}
/*
Table field getters
*/
@ -287,6 +306,17 @@ bool getboolfield(lua_State *L, int table,
return got;
}
bool getstringlistfield(lua_State *L, int table, const char *fieldname,
std::vector<const char *> &result)
{
lua_getfield(L, table, fieldname);
bool got = read_stringlist(L, -1, result);
lua_pop(L, 1);
return got;
}
std::string checkstringfield(lua_State *L, int table,
const char *fieldname)
{