summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index c8c1ca0e1..cd5d253ac 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -657,7 +657,8 @@ int ModApiEnvMod::l_clear_objects(lua_State *L)
}
// line_of_sight(pos1, pos2, stepsize) -> true/false, pos
-int ModApiEnvMod::l_line_of_sight(lua_State *L) {
+int ModApiEnvMod::l_line_of_sight(lua_State *L)
+{
float stepsize = 1.0;
GET_ENV_PTR;
@@ -681,6 +682,37 @@ int ModApiEnvMod::l_line_of_sight(lua_State *L) {
return 1;
}
+// delete_area(p1, p2)
+// delete mapblocks in area p1..p2
+int ModApiEnvMod::l_delete_area(lua_State *L)
+{
+ GET_ENV_PTR;
+
+ v3s16 bpmin = getNodeBlockPos(read_v3s16(L, 1));
+ v3s16 bpmax = getNodeBlockPos(read_v3s16(L, 2));
+ sortBoxVerticies(bpmin, bpmax);
+
+ ServerMap &map = env->getServerMap();
+
+ MapEditEvent event;
+ event.type = MEET_OTHER;
+
+ bool success = true;
+ for (s16 z = bpmin.Z; z <= bpmax.Z; z++)
+ for (s16 y = bpmin.Y; y <= bpmax.Y; y++)
+ for (s16 x = bpmin.X; x <= bpmax.X; x++) {
+ v3s16 bp(x, y, z);
+ if (map.deleteBlock(bp))
+ event.modified_blocks.insert(bp);
+ else
+ success = false;
+ }
+
+ map.dispatchEvent(&event);
+ lua_pushboolean(L, success);
+ return 1;
+}
+
// find_path(pos1, pos2, searchdistance,
// max_jump, max_drop, algorithm) -> table containing path
int ModApiEnvMod::l_find_path(lua_State *L)
@@ -849,6 +881,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
API_FCT(get_gametime);
API_FCT(find_node_near);
API_FCT(find_nodes_in_area);
+ API_FCT(delete_area);
API_FCT(get_perlin);
API_FCT(get_perlin_map);
API_FCT(get_voxel_manip);