summaryrefslogtreecommitdiff
path: root/src/script/common/c_converter.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-10-08 15:28:14 -0400
committerkwolekr <kwolekr@minetest.net>2014-10-26 23:55:45 -0400
commitd274cbfce6ed39f5b7ad41261ede8c0fad7e980a (patch)
treeb140fcc4ddb835e061bb5c0c94c5d0cab7742de0 /src/script/common/c_converter.cpp
parentb49e5cfc7013cef7e9af79d17e04f7e7e4c377d4 (diff)
downloadminetest-d274cbfce6ed39f5b7ad41261ede8c0fad7e980a.tar.gz
minetest-d274cbfce6ed39f5b7ad41261ede8c0fad7e980a.tar.bz2
minetest-d274cbfce6ed39f5b7ad41261ede8c0fad7e980a.zip
Add NodeResolver and clean up node name -> content ID resolution system
Diffstat (limited to 'src/script/common/c_converter.cpp')
-rw-r--r--src/script/common/c_converter.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index b2ef0573c..a906171d3 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -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)
{