1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add ability to delete MapBlocks from map

Also add a Lua API and chatcommand for this
This commit is contained in:
kwolekr 2015-01-15 16:20:05 -05:00
parent 0330cec7ec
commit 9736548720
15 changed files with 187 additions and 19 deletions

View file

@ -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);