Skip to content

Commit

Permalink
Radius parameter for /deleteblocks here
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker authored and Zeno- committed Mar 4, 2015
1 parent 40bf1d7 commit bbed01a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions builtin/game/chatcommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,27 @@ core.register_chatcommand("set", {
})

core.register_chatcommand("deleteblocks", {
params = "[here] [<pos1> <pos2>]",
params = "(here [radius]) | (<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 args = param:split(" ")
if args[1] == "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

if #args >= 2 then
local radius = tonumber(args[2]) or 0
p1 = vector.add(p1, radius)
p2 = vector.subtract(p2, radius)
end
else
local pos1, pos2 = unpack(param:split(") ("))
if pos1 == nil or pos2 == nil then
Expand Down

0 comments on commit bbed01a

Please sign in to comment.