aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/luaapi.cpp
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-08-02 00:29:27 +0200
committerPilzAdam <pilzadam@minetest.net>2013-08-02 00:55:16 +0200
commit0b77588e87b0eeedd624eb0d6c2559aad10104ad (patch)
tree35614cde27a84348ea258af264c96135b864b0c3 /src/script/lua_api/luaapi.cpp
parent06cdce1e1231fb5946ac9750f9b53b53c6f7e5f8 (diff)
downloadminetest-0b77588e87b0eeedd624eb0d6c2559aad10104ad.tar.gz
minetest-0b77588e87b0eeedd624eb0d6c2559aad10104ad.tar.bz2
minetest-0b77588e87b0eeedd624eb0d6c2559aad10104ad.zip
Allow multiple 'wherein' nodes in oredef
Diffstat (limited to 'src/script/lua_api/luaapi.cpp')
-rw-r--r--src/script/lua_api/luaapi.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/script/lua_api/luaapi.cpp b/src/script/lua_api/luaapi.cpp
index 020d1cf32..0d4c7da7b 100644
--- a/src/script/lua_api/luaapi.cpp
+++ b/src/script/lua_api/luaapi.cpp
@@ -672,7 +672,6 @@ int ModApiBasic::l_register_ore(lua_State *L)
ore->ore_name = getstringfield_default(L, index, "ore", "");
ore->ore_param2 = (u8)getintfield_default(L, index, "ore_param2", 0);
- ore->wherein_name = getstringfield_default(L, index, "wherein", "");
ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1);
ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1);
ore->clust_size = getintfield_default(L, index, "clust_size", 0);
@@ -681,6 +680,21 @@ int ModApiBasic::l_register_ore(lua_State *L)
ore->flags = getflagsfield(L, index, "flags", flagdesc_ore);
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0.);
+ lua_getfield(L, index, "wherein");
+ if (lua_istable(L, -1)) {
+ int i = lua_gettop(L);
+ lua_pushnil(L);
+ while(lua_next(L, i) != 0) {
+ ore->wherein_names.push_back(lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ } else if (lua_isstring(L, -1)) {
+ ore->wherein_names.push_back(lua_tostring(L, -1));
+ } else {
+ ore->wherein_names.push_back("");
+ }
+ lua_pop(L, 1);
+
lua_getfield(L, index, "noise_params");
ore->np = read_noiseparams(L, -1);
lua_pop(L, 1);