diff options
author | Anthony Zhang <azhang9@gmail.com> | 2012-09-25 18:42:10 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2012-09-25 18:42:10 -0400 |
commit | def676cd2d12e16a3fc7e2a1995166dd65d5a1a3 (patch) | |
tree | c114b2f9dd7d3f1c5f9d08816c24e8083a486d33 /init.lua | |
parent | d89fded397184bebe333ceec0f6f48bb7c55378b (diff) |
Add worldedit.hollow_sphere, worldedit.sphere, //hollowsphere, and //sphere, improve cylinder docs slightly.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -189,6 +189,58 @@ minetest.register_chatcommand("/replace", { end,
})
+minetest.register_chatcommand("/hollowsphere", {
+ params = "<radius> <node>",
+ description = "Add hollow sphere at WorldEdit position 1 with radius <radius>, composed of <node>",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos = worldedit.pos1[name]
+ if pos == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
+ if found == nil then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+ if not worldedit.node_is_valid(pos, nodename) then
+ minetest.chat_send_player(name, "Invalid node name: " .. param)
+ return
+ end
+
+ local count = worldedit.hollow_sphere(pos, tonumber(radius), nodename)
+ minetest.chat_send_player(name, count .. " nodes added")
+ end,
+})
+
+minetest.register_chatcommand("/sphere", {
+ params = "<radius> <node>",
+ description = "Add sphere at WorldEdit position 1 with radius <radius>, composed of <node>",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos = worldedit.pos1[name]
+ if pos == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
+ if found == nil then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+ if not worldedit.node_is_valid(pos, nodename) then
+ minetest.chat_send_player(name, "Invalid node name: " .. param)
+ return
+ end
+
+ local count = worldedit.sphere(pos, tonumber(radius), nodename)
+ minetest.chat_send_player(name, count .. " nodes added")
+ end,
+})
+
minetest.register_chatcommand("/hollowcylinder", {
params = "x/y/z/? <length> <radius> <node>",
description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>",
|