aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-02-15 19:46:57 -0500
committerkwolekr <kwolekr@minetest.net>2014-02-15 19:46:57 -0500
commitc1638590577d487e620f9a037727b91a0f62ceea (patch)
tree5a9dd3fa3bbf8c52a8ced6b99bd93c51c808f0e1 /src/script/lua_api
parent3570f3e396acad4a6b5381d06c2dae5cf4e95fbd (diff)
downloadminetest-c1638590577d487e620f9a037727b91a0f62ceea.tar.gz
minetest-c1638590577d487e620f9a037727b91a0f62ceea.tar.bz2
minetest-c1638590577d487e620f9a037727b91a0f62ceea.zip
Schematic: Add force_placement parameter to minetest.place_structure API
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mapgen.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index a7af856de..d34620056 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -599,9 +599,8 @@ int ModApiMapgen::l_place_schematic(lua_State *L)
dschem.rotation = (Rotation)rot;
if (lua_istable(L, 4)) {
- int index = 4;
lua_pushnil(L);
- while (lua_next(L, index) != 0) {
+ while (lua_next(L, 4) != 0) {
// key at index -2 and value at index -1
lua_rawgeti(L, -1, 1);
std::string replace_from = lua_tostring(L, -1);
@@ -615,6 +614,10 @@ int ModApiMapgen::l_place_schematic(lua_State *L)
}
}
+ bool force_placement = true;
+ if (lua_isboolean(L, 5))
+ force_placement = lua_toboolean(L, 5);
+
if (!dschem.filename.empty()) {
if (!dschem.loadSchematicFile()) {
errorstream << "place_schematic: failed to load schematic file '"
@@ -624,7 +627,7 @@ int ModApiMapgen::l_place_schematic(lua_State *L)
dschem.resolveNodeNames(ndef);
}
- dschem.placeStructure(map, p);
+ dschem.placeStructure(map, p, force_placement);
return 1;
}