From 0b77588e87b0eeedd624eb0d6c2559aad10104ad Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Fri, 2 Aug 2013 00:29:27 +0200 Subject: Allow multiple 'wherein' nodes in oredef --- src/script/lua_api/luaapi.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/script') 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); -- cgit v1.2.3