summaryrefslogtreecommitdiff
path: root/worldedit_commands
diff options
context:
space:
mode:
authorSebastien Ponce <Sebastien.Ponce@cern.ch>2015-09-13 11:31:47 +0200
committerSebastien Ponce <Sebastien.Ponce@cern.ch>2015-09-13 22:08:04 +0200
commit5f9efb1205fe9802f859548fc9220f98dd0fd12e (patch)
tree39d5bd7cf4cb71b2f7eac71465199d881f797d68 /worldedit_commands
parentfc037e9c82f34a6bf441dd738c1b10a510eb8b4d (diff)
Added hollow pyramids
Diffstat (limited to 'worldedit_commands')
-rw-r--r--worldedit_commands/init.lua50
1 files changed, 34 insertions, 16 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index 83a127e..08a9811 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -516,9 +516,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+(.+)$")
@@ -528,24 +544,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", {