From def676cd2d12e16a3fc7e2a1995166dd65d5a1a3 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Tue, 25 Sep 2012 18:42:10 -0400 Subject: Add worldedit.hollow_sphere, worldedit.sphere, //hollowsphere, and //sphere, improve cylinder docs slightly. --- init.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 1e9b0ef..a7e1947 100644 --- a/init.lua +++ b/init.lua @@ -189,6 +189,58 @@ minetest.register_chatcommand("/replace", { end, }) +minetest.register_chatcommand("/hollowsphere", { + params = " ", + description = "Add hollow sphere at WorldEdit position 1 with radius , composed of ", + 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 = " ", + description = "Add sphere at WorldEdit position 1 with radius , composed of ", + 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/? ", description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of ", -- cgit v1.2.3