diff --git a/worldedit/primitives.lua b/worldedit/primitives.lua index e056c73..c7585aa 100644 --- a/worldedit/primitives.lua +++ b/worldedit/primitives.lua @@ -52,7 +52,7 @@ end -- @param node_name Name of node to make torus of. -- @param hollow Whether the torus should be hollow. -- @return The number of nodes added. -function worldedit.torus(pos, radius, tr, node_name, hollow) +function worldedit.torus(pos, radius, tr, node_name) local radius_out=radius+tr local radius_in=radius-tr local manip, area = mh.init_radius(pos, radius_out) diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index dff5934..38e39cd 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -698,7 +698,12 @@ local check_torus = function(param) if not node then return false, "invalid node name: " .. nodename end - return true, tonumber(radius), tonumber(tr), node + local n_radius= tonumber(radius) + local tr = tonumber(tr) + if tr>n_radius then + return false, "Thickness cannot be greater than radius" + end + return true, radius, tr, node end @@ -737,7 +742,7 @@ worldedit.register_command("torus", { require_pos = 1, parse = check_torus, nodes_needed = function(name, radius, tr, node) - return math.ceil((4 * math.pi * (radius ^ 3)) / 3) --volume of sphere + return math.ceil( 2 * math.pi * math.pi * radius *tr *tr) end, func = function(name, radius, tr, node) local count = worldedit.torus(worldedit.pos1[name], radius, tr, node)