+bool check_field_or_nil(lua_State *L, int index, int type, const char *fieldname);
+
+template<typename T>
+bool getintfield(lua_State *L, int table,
+ const char *fieldname, T &result)
+{
+ lua_getfield(L, table, fieldname);
+ bool got = false;
+ if (check_field_or_nil(L, -1, LUA_TNUMBER, fieldname)){
+ result = lua_tointeger(L, -1);
+ got = true;
+ }
+ lua_pop(L, 1);
+ return got;
+}
+
+template<class T>
+bool getv3intfield(lua_State *L, int index,
+ const char *fieldname, T &result)
+{
+ lua_getfield(L, index, fieldname);
+ bool got = false;
+ if (lua_istable(L, -1)) {
+ got |= getintfield(L, -1, "x", result.X);
+ got |= getintfield(L, -1, "y", result.Y);
+ got |= getintfield(L, -1, "z", result.Z);
+ }
+ lua_pop(L, 1);
+ return got;
+}
+
+v3s16 getv3s16field_default(lua_State *L, int table,
+ const char *fieldname, v3s16 default_);