diff options
author | kwolekr <kwolekr@minetest.net> | 2013-12-01 01:23:39 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-12-01 01:24:59 -0500 |
commit | 20e3d550fa3ec42a065f7c776a2f9be9bc364503 (patch) | |
tree | 50fbcc15da2bda6f3d91fb88c6bea5d0d346c5a8 /src/script | |
parent | de0cdbc01cc39e4f89a9d012661031a66ba3294f (diff) | |
download | minetest-20e3d550fa3ec42a065f7c776a2f9be9bc364503.tar.gz minetest-20e3d550fa3ec42a065f7c776a2f9be9bc364503.tar.bz2 minetest-20e3d550fa3ec42a065f7c776a2f9be9bc364503.zip |
Decoration: Add schematic Y-slice probability support
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index b0ad202be..de9b5aba7 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -475,7 +475,7 @@ int ModApiMapgen::l_create_schematic(lua_State *L) v3s16 p2 = read_v3s16(L, 2); sortBoxVerticies(p1, p2); - std::vector<std::pair<v3s16, u8> > probability_list; + std::vector<std::pair<v3s16, u8> > prob_list; if (lua_istable(L, 3)) { lua_pushnil(L); while (lua_next(L, 3)) { @@ -485,22 +485,37 @@ int ModApiMapgen::l_create_schematic(lua_State *L) lua_pop(L, 1); u8 prob = getintfield_default(L, -1, "prob", MTSCHEM_PROB_ALWAYS); - probability_list.push_back(std::make_pair(pos, prob)); + prob_list.push_back(std::make_pair(pos, prob)); } lua_pop(L, 1); } } - dschem.filename = std::string(lua_tostring(L, 4)); + std::vector<std::pair<s16, u8> > slice_prob_list; + if (lua_istable(L, 5)) { + lua_pushnil(L); + while (lua_next(L, 5)) { + if (lua_istable(L, -1)) { + s16 ypos = getintfield_default(L, -1, "ypos", 0); + u8 prob = getintfield_default(L, -1, "prob", MTSCHEM_PROB_ALWAYS); + slice_prob_list.push_back(std::make_pair(ypos, prob)); + } + + lua_pop(L, 1); + } + } + + const char *s = lua_tostring(L, 4); + dschem.filename = std::string(s ? s : ""); if (!dschem.getSchematicFromMap(map, p1, p2)) { errorstream << "create_schematic: failed to get schematic " "from map" << std::endl; return 0; } - - dschem.applyProbabilities(&probability_list, p1); + + dschem.applyProbabilities(p1, &prob_list, &slice_prob_list); dschem.saveSchematicFile(ndef); actionstream << "create_schematic: saved schematic file '" |