//sphere 12 default:glass\r
//sphere 17 mesecons:mesecon\r
\r
+### //hollowdome <radius> <node>\r
+\r
+Add hollow dome at WorldEdit position 1 with radius <radius>, composed of <node>.\r
+\r
+ //hollowdome 5 dirt\r
+ //hollowdome 12 default:glass\r
+ //hollowdome 17 mesecons:mesecon\r
+\r
+### //dome <radius> <node>\r
+\r
+Add dome at WorldEdit position 1 with radius <radius>, composed of <node>.\r
+\r
+ //dome 5 dirt\r
+ //dome 12 default:glass\r
+ //dome 17 mesecons:mesecon\r
+\r
### //hollowcylinder x/y/z/? <length> <radius> <node>\r
\r
Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>.\r
\r
Returns the number of nodes added.\r
\r
+### count = worldedit.hollow_dome(pos, radius, nodename)\r
+\r
+Adds a hollow dome at `pos` with radius `radius`, composed of `nodename`.\r
+\r
+Returns the number of nodes added.\r
+\r
+### count = worldedit.dome(pos, radius, nodename)\r
+\r
+Adds a dome at `pos` with radius `radius`, composed of `nodename`.\r
+\r
+Returns the number of nodes added.\r
+\r
### count = worldedit.hollow_cylinder(pos, axis, length, radius, nodename)\r
\r
Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.\r
worldedit = worldedit or {}\r
\r
--adds a hollow sphere at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added\r
-worldedit.hollow_sphere = function(pos, radius, nodename) --wip: use bresenham sphere for maximum speed\r
+worldedit.hollow_sphere = function(pos, radius, nodename)\r
local node = {name=nodename}\r
local pos1 = {x=0, y=0, z=0}\r
- local full_radius = radius * radius + radius\r
+ local min_radius = radius * (radius - 1)\r
+ local max_radius = radius * (radius + 1)\r
local count = 0\r
local env = minetest.env\r
for x = -radius, radius do\r
for y = -radius, radius do\r
pos1.y = pos.y + y\r
for z = -radius, radius do\r
- if x*x+y*y+z*z >= (radius-1) * (radius-1) + (radius-1) and x*x+y*y+z*z <= full_radius then\r
+ if x*x+y*y+z*z >= min_radius and x*x+y*y+z*z <= max_radius then\r
pos1.z = pos.z + z\r
- env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z}, node)\r
+ env:add_node(pos1, node)\r
count = count + 1\r
end\r
end\r
end\r
\r
--adds a sphere at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added\r
-worldedit.sphere = function(pos, radius, nodename) --wip: use bresenham sphere for maximum speed\r
+worldedit.sphere = function(pos, radius, nodename)\r
local node = {name=nodename}\r
local pos1 = {x=0, y=0, z=0}\r
- local full_radius = radius * radius + radius\r
+ local max_radius = radius * (radius + 1)\r
local count = 0\r
local env = minetest.env\r
for x = -radius, radius do\r
for y = -radius, radius do\r
pos1.y = pos.y + y\r
for z = -radius, radius do\r
- if x*x+y*y+z*z <= full_radius then\r
+ if x*x+y*y+z*z <= max_radius then\r
+ pos1.z = pos.z + z\r
+ env:add_node(pos1, node)\r
+ count = count + 1\r
+ end\r
+ end\r
+ end\r
+ end\r
+ return count\r
+end\r
+\r
+--adds a hollow dome at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added\r
+worldedit.hollow_dome = function(pos, radius, nodename) --wip: use bresenham sphere for maximum speed\r
+ local node = {name=nodename}\r
+ local pos1 = {x=0, y=0, z=0}\r
+ local min_radius = radius * (radius - 1)\r
+ local max_radius = radius * (radius + 1)\r
+ local count = 0\r
+ local env = minetest.env\r
+ for x = -radius, radius do\r
+ pos1.x = pos.x + x\r
+ for y = 0, radius do\r
+ pos1.y = pos.y + y\r
+ for z = -radius, radius do\r
+ if x*x+y*y+z*z >= min_radius and x*x+y*y+z*z <= max_radius then\r
+ pos1.z = pos.z + z\r
+ env:add_node(pos1, node)\r
+ count = count + 1\r
+ end\r
+ end\r
+ end\r
+ end\r
+ return count\r
+end\r
+\r
+--adds a dome at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added\r
+worldedit.dome = function(pos, radius, nodename) --wip: use bresenham sphere for maximum speed\r
+ local node = {name=nodename}\r
+ local pos1 = {x=0, y=0, z=0}\r
+ local max_radius = radius * (radius + 1)\r
+ local count = 0\r
+ local env = minetest.env\r
+ for x = -radius, radius do\r
+ pos1.x = pos.x + x\r
+ for y = 0, radius do\r
+ pos1.y = pos.y + y\r
+ for z = -radius, radius do\r
+ if x*x+y*y+z*z <= max_radius then\r
pos1.z = pos.z + z\r
env:add_node(pos1, node)\r
count = count + 1\r
end,\r
})\r
\r
+minetest.register_chatcommand("/hollowdome", {\r
+ params = "<radius> <node>",\r
+ description = "Add hollow dome at WorldEdit position 1 with radius <radius>, composed of <node>",\r
+ privs = {worldedit=true},\r
+ func = function(name, param)\r
+ local pos = worldedit.pos1[name]\r
+ if pos == nil then\r
+ minetest.chat_send_player(name, "No WorldEdit region selected", false)\r
+ return\r
+ end\r
+\r
+ local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")\r
+ if found == nil then\r
+ minetest.chat_send_player(name, "Invalid usage: " .. param, false)\r
+ return\r
+ end\r
+ if not worldedit.node_is_valid(nodename) then\r
+ minetest.chat_send_player(name, "Invalid node name: " .. param, false)\r
+ return\r
+ end\r
+\r
+ local count = worldedit.hollow_dome(pos, tonumber(radius), nodename)\r
+ minetest.chat_send_player(name, count .. " nodes added", false)\r
+ end,\r
+})\r
+\r
+minetest.register_chatcommand("/dome", {\r
+ params = "<radius> <node>",\r
+ description = "Add dome at WorldEdit position 1 with radius <radius>, composed of <node>",\r
+ privs = {worldedit=true},\r
+ func = function(name, param)\r
+ local pos = worldedit.pos1[name]\r
+ if pos == nil then\r
+ minetest.chat_send_player(name, "No WorldEdit region selected", false)\r
+ return\r
+ end\r
+\r
+ local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")\r
+ if found == nil then\r
+ minetest.chat_send_player(name, "Invalid usage: " .. param, false)\r
+ return\r
+ end\r
+ if not worldedit.node_is_valid(nodename) then\r
+ minetest.chat_send_player(name, "Invalid node name: " .. param, false)\r
+ return\r
+ end\r
+\r
+ local count = worldedit.dome(pos, tonumber(radius), nodename)\r
+ minetest.chat_send_player(name, count .. " nodes added", false)\r
+ end,\r
+})\r
+\r
minetest.register_chatcommand("/hollowcylinder", {\r
params = "x/y/z/? <length> <radius> <node>",\r
description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>",\r