From a82ab9176f831b4f1beb9d2f3c3a7d582abf8b44 Mon Sep 17 00:00:00 2001 From: Brett O'Donnell Date: Wed, 26 Sep 2012 18:36:11 -0400 Subject: Fix worldedit.spiral and the correspondign chat command, //spiral. --- init.lua | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index da462c5..84cf4fe 100644 --- a/init.lua +++ b/init.lua @@ -271,6 +271,36 @@ minetest.register_chatcommand("/hollowcylinder", { end, }) +minetest.register_chatcommand("/cylinder", { + params = "x/y/z/? ", + description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length and 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, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") + if found == nil then + minetest.chat_send_player(name, "Invalid usage: " .. param) + return + end + if axis == "?" then + axis, sign = worldedit.player_axis(name) + length = length * sign + end + if not worldedit.node_is_valid(pos, nodename) then + minetest.chat_send_player(name, "Invalid node name: " .. param) + return + end + + local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), nodename) + minetest.chat_send_player(name, count .. " nodes added") + end, +}) + minetest.register_chatcommand("/pyramid", { params = " ", description = "Add pyramid at WorldEdit position 1 with height , composed of ", @@ -297,9 +327,9 @@ minetest.register_chatcommand("/pyramid", { end, }) -minetest.register_chatcommand("/cylinder", { - params = "x/y/z/? ", - description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of ", +minetest.register_chatcommand("/spiral", { + params = " ", + description = "Add spiral at WorldEdit position 1 with width , height , space between walls , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] @@ -308,22 +338,18 @@ minetest.register_chatcommand("/cylinder", { return end - local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") + local found, _, width, height, space, nodename = param:find("(%d+)%s+(%d+)%s+(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param) return end - if axis == "?" then - axis, sign = worldedit.player_axis(name) - length = length * sign - end if not worldedit.node_is_valid(pos, nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param) return end - local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), nodename) - minetest.chat_send_player(name, count .. " nodes added") + local count = worldedit.spiral(pos, tonumber(width), tonumber(height), tonumber(space), nodename) + minetest.chat_send_player(name, count .. " nodes changed") end, }) -- cgit v1.2.3