+local check_cube = function(name, param)\r
+ if worldedit.pos1[name] == nil then\r
+ worldedit.player_notify(name, "no position 1 selected")\r
+ return nil\r
+ end\r
+ local found, _, w, h, l, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
+ if found == nil then\r
+ worldedit.player_notify(name, "invalid usage: " .. param)\r
+ return nil\r
+ end\r
+ local node = get_node(name, nodename)\r
+ if not node then return nil end\r
+ return tonumber(w) * tonumber(h) * tonumber(l)\r
+end\r
+\r
+minetest.register_chatcommand("/hollowcube", {\r
+ params = "<width> <height> <length> <node>",\r
+ description = "Add a hollow cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.",\r
+ privs = {worldedit=true},\r
+ func = safe_region(function(name, param)\r
+ local found, _, w, h, l, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
+ local node = get_node(name, nodename)\r
+ local count = worldedit.cube(worldedit.pos1[name], tonumber(w), tonumber(h), tonumber(l), node, true)\r
+ worldedit.player_notify(name, count .. " nodes added")\r
+ end, check_cube),\r
+})\r
+\r
+minetest.register_chatcommand("/cube", {\r
+ params = "<width> <height> <length> <node>",\r
+ description = "Add a cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.",\r
+ privs = {worldedit=true},\r
+ func = safe_region(function(name, param)\r
+ local found, _, w, h, l, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
+ local node = get_node(name, nodename)\r
+ local count = worldedit.cube(worldedit.pos1[name], tonumber(w), tonumber(h), tonumber(l), node)\r
+ worldedit.player_notify(name, count .. " nodes added")\r
+ end, check_cube),\r
+})\r
+\r