//replace dirt flowers:flower_waterlily
//replace flowers:flower_rose flowers:flower_tulip
+### //hollowsphere <radius> <node>
+
+Add hollow sphere at WorldEdit position 1 with radius <radius>, composed of <node>.
+
+ //hollowsphere 5 dirt
+ //hollowsphere 12 default:glass
+ //hollowsphere 17 mesecons:mesecon
+
+### //sphere <radius> <node>
+
+Add sphere at WorldEdit position 1 with radius <radius>, composed of <node>.
+
+ //sphere 5 dirt
+ //sphere 12 default:glass
+ //sphere 17 mesecons:mesecon
+
### //hollowcylinder x/y/z/? <length> <radius> <node>
Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>.
Returns the number of nodes replaced.
+### worldedit.hollow_sphere = function(pos, radius, nodename)
+
+Adds a hollow sphere at `pos` with radius `radius`, composed of `nodename`.
+
+Returns the number of nodes added.
+
+### worldedit.sphere = function(pos, radius, nodename)
+
+Adds a sphere at `pos` with radius `radius`, composed of `nodename`.
+
+Returns the number of nodes added.
+
### worldedit.hollow_cylinder(pos, axis, length, radius, nodename)
-Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`.
+Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.
Returns the number of nodes added.
### worldedit.cylinder(pos, axis, length, radius, nodename)
-Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`.
+Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`.
Returns the number of nodes added.
License
-------
-Copyright 2012 sfan5, Anthony Zhang (Temperest), and Brett O'Donnell (cornernote).
+Copyright 2012 sfan5 and Anthony Zhang (Temperest)
This mod is licensed under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.html).
return count\r
end\r
\r
---adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, returning the number of nodes added\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)\r
+ local node = {name=nodename}\r
+ local pos1 = {x=0, y=0, z=0}\r
+ local full_radius = radius * radius + radius\r
+ local env = minetest.env\r
+ for x = -radius, radius do\r
+ pos1.x = pos.x + x\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
+ pos1.z = pos.z + z\r
+ env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z}, node)\r
+ end\r
+ end\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)\r
+ local node = {name=nodename}\r
+ local pos1 = {x=0, y=0, z=0}\r
+ local full_radius = radius * radius + radius\r
+ local count = 0\r
+ local env = minetest.env\r
+ for x = -radius, radius do\r
+ pos1.x = pos.x + x\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
+ 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 cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`, returning the number of nodes added\r
worldedit.hollow_cylinder = function(pos, axis, length, radius, nodename)\r
local other1, other2\r
if axis == "x" then\r
return count\r
end\r
\r
---adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, returning the number of nodes added\r
+--adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`, returning the number of nodes added\r
worldedit.cylinder = function(pos, axis, length, radius, nodename)\r
local other1, other2\r
if axis == "x" then\r
return count\r
end\r
\r
---adds a spiral at `pos` with size `size`, returning the number of nodes changed\r
+--adds a spiral at `pos` with size `size`, composed of `nodename`, returning the number of nodes changed\r
worldedit.spiral = function(pos, size, nodename)\r
local shift_x, shift_y\r
sa = spiralt(size)\r
end,\r
})\r
\r
+minetest.register_chatcommand("/hollowsphere", {\r
+ params = "<radius> <node>",\r
+ description = "Add hollow sphere 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")\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)\r
+ return\r
+ end\r
+ if not worldedit.node_is_valid(pos, nodename) then\r
+ minetest.chat_send_player(name, "Invalid node name: " .. param)\r
+ return\r
+ end\r
+\r
+ local count = worldedit.hollow_sphere(pos, tonumber(radius), nodename)\r
+ minetest.chat_send_player(name, count .. " nodes added")\r
+ end,\r
+})\r
+\r
+minetest.register_chatcommand("/sphere", {\r
+ params = "<radius> <node>",\r
+ description = "Add sphere 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")\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)\r
+ return\r
+ end\r
+ if not worldedit.node_is_valid(pos, nodename) then\r
+ minetest.chat_send_player(name, "Invalid node name: " .. param)\r
+ return\r
+ end\r
+\r
+ local count = worldedit.sphere(pos, tonumber(radius), nodename)\r
+ minetest.chat_send_player(name, count .. " nodes added")\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