diff options
author | kwolekr <kwolekr@minetest.net> | 2015-01-15 16:20:05 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-01-15 16:48:56 -0500 |
commit | 9736548720a96c9c7f739edb0435d9ba4ad80652 (patch) | |
tree | 3f92b63d017e9baac042ed3837bbdf040d40c73f /builtin | |
parent | 0330cec7ec55126c9cc441373cde1253bed895ee (diff) | |
download | minetest-9736548720a96c9c7f739edb0435d9ba4ad80652.tar.gz minetest-9736548720a96c9c7f739edb0435d9ba4ad80652.tar.bz2 minetest-9736548720a96c9c7f739edb0435d9ba4ad80652.zip |
Add ability to delete MapBlocks from map
Also add a Lua API and chatcommand for this
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/chatcommands.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 4f7b031aa..18b5dbe72 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -403,6 +403,46 @@ core.register_chatcommand("set", { end, }) +core.register_chatcommand("deleteblocks", { + params = "[here] [<pos1> <pos2>]", + description = "delete map blocks contained in area pos1 to pos2", + privs = {server=true}, + func = function(name, param) + local p1 = {} + local p2 = {} + if param == "here" then + local player = core.get_player_by_name(name) + if player == nil then + core.log("error", "player is nil") + return false, "Unable to get current position; player is nil" + end + p1 = player:getpos() + p2 = p1 + else + p1.x, p1.y, p1.z, p2.x, p2.y, p2.z = string.match(param, + "^%(([%d.-]+), *([%d.-]+), *([%d.-]+)%) *%(([%d.-]+), *([%d.-]+), *([%d.-]+)%)$") + p1.x = tonumber(p1.x) + p1.y = tonumber(p1.y) + p1.z = tonumber(p1.z) + p2.x = tonumber(p2.x) + p2.y = tonumber(p2.y) + p2.z = tonumber(p2.z) + + if p1.x == nil or p1.y == nil or p1.z == nil or + p2.x == nil or p2.y == nil or p2.z == nil then + return false, "Incorrect area format. Expected: (x1,y1,z1) (x2,y2,z2)" + end + end + + if core.delete_area(p1, p2) then + return true, "Successfully cleared area ranging from " .. + core.pos_to_string(p1) .. " to " .. core.pos_to_string(p2) + else + return false, "Failed to clear one or more blocks in area" + end + end, +}) + core.register_chatcommand("mods", { params = "", description = "List mods installed on the server", |