From e610eb7a92cce77bdb62d51b4ac04c5f3cde1106 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 31 Oct 2021 16:42:12 +0000 Subject: [PATCH] //spiral2: fix bugs --- .../commands/spiral2.lua | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/worldeditadditions_commands/commands/spiral2.lua b/worldeditadditions_commands/commands/spiral2.lua index eb94f56..e8efc06 100644 --- a/worldeditadditions_commands/commands/spiral2.lua +++ b/worldeditadditions_commands/commands/spiral2.lua @@ -8,9 +8,9 @@ worldedit.register_command("spiral2", { privs = { worldedit = true }, require_pos = 2, parse = function(params_text) - if not params_text then return true, "circle", "dirt" end + if not params_text then params_text = "" end params_text = wea.trim(params_text) - if params_text == "" then return true, "circle", "dirt" end + if params_text == "" then return true, "circle", "dirt", 3, 0 end local parts = wea.split_shell(params_text) @@ -23,6 +23,7 @@ worldedit.register_command("spiral2", { if parts[1] ~= "circle" and parts[1] ~= "square" then target_node = parts[1] target_node_found = true + table.remove(parts, 1) else mode = parts[1] table.remove(parts, 1) @@ -34,10 +35,16 @@ worldedit.register_command("spiral2", { end if #parts >= 1 then interval = tonumber(parts[1]) + if not interval then + return false, "Error: Invalid interval value '"..parts[1].."'. Interval values must be integers." + end table.remove(parts, 1) end if #parts >= 1 then - acceleration = tonumber(parts[3]) + acceleration = tonumber(parts[1]) + if not acceleration then + return false, "Error: Invalid acceleration value '"..parts[1].."'. Acceleration values must be integers." + end table.remove(parts, 1) end @@ -46,13 +53,6 @@ worldedit.register_command("spiral2", { return false, "Error: Unknown node '"..target_node_norm.."'." end - if not interval then - return false, "Error: Invalid interval value. Interval values must be integers." - end - if not acceleration then - return false, "Error: Invalid acceleration value. Acceleration values must be integers." - end - return true, mode, target_node_norm, interval, acceleration end, nodes_needed = function(name) @@ -66,7 +66,12 @@ worldedit.register_command("spiral2", { local success, count if mode == "circle" then - return false, "Error: Not implemented yet. Coming soon!" + success, count = wea.spiral_circle( + pos1, pos2, + target_node, + interval, acceleration + ) + if not success then return success, count end else success, count = wea.spiral_square( pos1, pos2,