summaryrefslogtreecommitdiff
path: root/worldedit_commands
diff options
context:
space:
mode:
Diffstat (limited to 'worldedit_commands')
-rw-r--r--worldedit_commands/init.lua52
-rw-r--r--worldedit_commands/mark.lua6
2 files changed, 40 insertions, 18 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index ca2b9e4..b9313cc 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -517,9 +517,25 @@ minetest.register_chatcommand("/cylinder", {
end, check_cylinder),
})
-minetest.register_chatcommand("/pyramid", {
+local check_pyramid = function(name, param)
+ if worldedit.pos1[name] == nil then
+ worldedit.player_notify(name, "no position 1 selected")
+ return nil
+ end
+ local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")
+ if found == nil then
+ worldedit.player_notify(name, "invalid usage: " .. param)
+ return nil
+ end
+ local node = get_node(name, nodename)
+ if not node then return nil end
+ height = tonumber(height)
+ return math.ceil(((height * 2 + 1) ^ 2) * height / 3)
+end
+
+minetest.register_chatcommand("/hollowpyramid", {
params = "x/y/z/? <height> <node>",
- description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",
+ description = "Add hollow pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",
privs = {worldedit=true},
func = safe_region(function(name, param)
local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")
@@ -529,24 +545,26 @@ minetest.register_chatcommand("/pyramid", {
height = height * sign
end
local node = get_node(name, nodename)
- local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)
+ local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node, true)
worldedit.player_notify(name, count .. " nodes added")
- end,
- function(name, param)
- if worldedit.pos1[name] == nil then
- worldedit.player_notify(name, "no position 1 selected")
- return nil
- end
+ end, check_pyramid),
+})
+
+minetest.register_chatcommand("/pyramid", {
+ params = "x/y/z/? <height> <node>",
+ description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",
+ privs = {worldedit=true},
+ func = safe_region(function(name, param)
local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")
- if found == nil then
- worldedit.player_notify(name, "invalid usage: " .. param)
- return nil
+ height = tonumber(height)
+ if axis == "?" then
+ axis, sign = worldedit.player_axis(name)
+ height = height * sign
end
local node = get_node(name, nodename)
- if not node then return nil end
- height = tonumber(height)
- return math.ceil(((height * 2 + 1) ^ 2) * height / 3)
- end),
+ local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)
+ worldedit.player_notify(name, count .. " nodes added")
+ end, check_pyramid),
})
minetest.register_chatcommand("/spiral", {
@@ -571,7 +589,7 @@ minetest.register_chatcommand("/spiral", {
end
local node = get_node(name, nodename)
if not node then return nil end
- return check_region(name, param)
+ return 1 -- TODO: return an useful value
end),
})
diff --git a/worldedit_commands/mark.lua b/worldedit_commands/mark.lua
index 4062cae..7f880ea 100644
--- a/worldedit_commands/mark.lua
+++ b/worldedit_commands/mark.lua
@@ -153,7 +153,11 @@ minetest.register_entity(":worldedit:region_cube", {
end
end,
on_punch = function(self, hitter)
- for _, entity in ipairs(worldedit.marker_region[self.player_name]) do
+ local markers = worldedit.marker_region[self.player_name]
+ if not markers then
+ return
+ end
+ for _, entity in ipairs(markers) do
entity:remove()
end
worldedit.marker_region[self.player_name] = nil