| `//hdo` | `//hollowdome` |\r
| `//do` | `//dome` |\r
| `//hcyl` | `//hollowcylinder` |\r
+| `//cyl` | `//cylinder` |\r
+| `//hpyr` | `//hollowpyramid` |\r
+| `//pyr` | `//pyramid` |\r
\r
### `//about`\r
\r
//cylinder z -12 3 mesecons:wire_00000000_off\r
//cylinder ? 2 4 default:stone\r
\r
+### `//hollowpyramid x/y/z? <height> <node>`\r
+\r
+Add hollow pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height `<height>`, composed of `<node>`.\r
+\r
+ //hollowpyramid x 8 Diamond Block\r
+ //hollowpyramid y -5 glass\r
+ //hollowpyramid z 2 mesecons:wire_00000000_off\r
+ //hollowpyramid ? 12 mesecons:wire_00000000_off\r
+\r
### `//pyramid x/y/z? <height> <node>`\r
\r
Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height `<height>`, composed of `<node>`.\r
\r
Returns the number of nodes added.\r
\r
-### count = worldedit.pyramid(pos, axis, height, node_name)\r
+### count = worldedit.pyramid(pos, axis, height, node_name, hollow)\r
\r
-Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`.\r
+Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`, composed of `node_name`.\r
\r
Returns the number of nodes added.\r
\r
-- @param axis Axis ("x", "y", or "z")\r
-- @param height Pyramid height.\r
-- @param node_name Name of node to make pyramid of.\r
+-- @param hollow Whether the pyramid should be hollow.\r
-- @return The number of nodes added.\r
-function worldedit.pyramid(pos, axis, height, node_name)\r
+function worldedit.pyramid(pos, axis, height, node_name, hollow)\r
local other1, other2 = worldedit.get_axis_others(axis)\r
\r
-- Set up voxel manipulator\r
local new_index2 = new_index1 + (index2 + offset[other1]) * stride[other1]\r
for index3 = -size, size do\r
local i = new_index2 + (index3 + offset[other2]) * stride[other2]\r
- data[i] = node_id\r
+ if (not hollow or size - math.abs(index2) < 2 or size - math.abs(index3) < 2) then\r
+ data[i] = node_id\r
+ count = count + 1\r
+ end\r
end\r
end\r
- count = count + (size * 2 + 1) ^ 2\r
size = size - 1\r
end\r
\r
end, check_cylinder),\r
})\r
\r
-minetest.register_chatcommand("/pyramid", {\r
+local check_pyramid = 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, _, axis, height, nodename = param:find("^([xyz%?])%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
+ height = tonumber(height)\r
+ return math.ceil(((height * 2 + 1) ^ 2) * height / 3)\r
+end\r
+ \r
+minetest.register_chatcommand("/hollowpyramid", {\r
params = "x/y/z/? <height> <node>",\r
- description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",\r
+ description = "Add hollow pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",\r
privs = {worldedit=true},\r
func = safe_region(function(name, param)\r
local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")\r
height = height * sign\r
end\r
local node = get_node(name, nodename)\r
- local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)\r
+ local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node, true)\r
worldedit.player_notify(name, count .. " nodes added")\r
- end,\r
- 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
+ end, check_pyramid),\r
+})\r
+\r
+minetest.register_chatcommand("/pyramid", {\r
+ params = "x/y/z/? <height> <node>",\r
+ description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",\r
+ privs = {worldedit=true},\r
+ func = safe_region(function(name, param)\r
local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")\r
- if found == nil then\r
- worldedit.player_notify(name, "invalid usage: " .. param)\r
- return nil\r
+ height = tonumber(height)\r
+ if axis == "?" then\r
+ axis, sign = worldedit.player_axis(name)\r
+ height = height * sign\r
end\r
local node = get_node(name, nodename)\r
- if not node then return nil end\r
- height = tonumber(height)\r
- return math.ceil(((height * 2 + 1) ^ 2) * height / 3)\r
- end),\r
+ local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)\r
+ worldedit.player_notify(name, count .. " nodes added")\r
+ end, check_pyramid),\r
})\r
\r
minetest.register_chatcommand("/spiral", {\r
or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_pyramid_length;Length;%s]", minetest.formspec_escape(length)) ..\r
string.format("dropdown[4,2.18;2.5;worldedit_gui_pyramid_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..\r
- "button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit;Pyramid]"\r
+ "button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit_hollow;Hollow Pyramid]" ..\r
+ "button_exit[3.5,3.5;3,0.8;worldedit_gui_pyramid_submit_solid;Solid Pyramid]"\r
end,\r
})\r
\r
worldedit.register_gui_handler("worldedit_gui_pyramid", function(name, fields)\r
- if fields.worldedit_gui_pyramid_search or fields.worldedit_gui_pyramid_submit then\r
+ if fields.worldedit_gui_pyramid_search or fields.worldedit_gui_pyramid_submit_solid or fields.worldedit_gui_pyramid_submit_hollow or fields.worldedit_gui_pyramid_axis then\r
gui_nodename1[name] = tostring(fields.worldedit_gui_pyramid_node)\r
gui_axis1[name] = axis_indices[fields.worldedit_gui_pyramid_axis]\r
gui_distance1[name] = tostring(fields.worldedit_gui_pyramid_length)\r
worldedit.show_page(name, "worldedit_gui_pyramid")\r
- if fields.worldedit_gui_pyramid_submit then\r
+ if fields.worldedit_gui_pyramid_submit_solid then\r
minetest.chatcommands["/pyramid"].func(name, string.format("%s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_nodename1[name]))\r
+ elseif fields.worldedit_gui_pyramid_submit_hollow then\r
+ minetest.chatcommands["/hollowpyramid"].func(name, string.format("%s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_nodename1[name]))\r
end\r
return true\r
end\r
worldedit.alias_chatcommand("/do", "/dome")\r
worldedit.alias_chatcommand("/hcyl", "/hollowcylinder")\r
worldedit.alias_chatcommand("/cyl", "/cylinder")\r
+worldedit.alias_chatcommand("/hpyr", "/hollowpyramid")\r
worldedit.alias_chatcommand("/pyr", "/pyramid")\r
worldedit.alias_chatcommand("/spl", "/spiral")\r
worldedit.alias_chatcommand("/m", "/move")\r
worldedit.alias_chatcommand("/rsr", "/restore")\r
worldedit.alias_chatcommand("/l", "/lua")\r
worldedit.alias_chatcommand("/lt", "/luatransform")\r
-worldedit.alias_chatcommand("/clro", "/clearobjects")
\ No newline at end of file
+worldedit.alias_chatcommand("/clro", "/clearobjects")\r