//spiral2: fix bugs

This commit is contained in:
Starbeamrainbowlabs 2021-10-31 16:42:12 +00:00
parent dae59b63db
commit e610eb7a92
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -8,9 +8,9 @@ worldedit.register_command("spiral2", {
privs = { worldedit = true }, privs = { worldedit = true },
require_pos = 2, require_pos = 2,
parse = function(params_text) 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) 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) local parts = wea.split_shell(params_text)
@ -23,6 +23,7 @@ worldedit.register_command("spiral2", {
if parts[1] ~= "circle" and parts[1] ~= "square" then if parts[1] ~= "circle" and parts[1] ~= "square" then
target_node = parts[1] target_node = parts[1]
target_node_found = true target_node_found = true
table.remove(parts, 1)
else else
mode = parts[1] mode = parts[1]
table.remove(parts, 1) table.remove(parts, 1)
@ -34,10 +35,16 @@ worldedit.register_command("spiral2", {
end end
if #parts >= 1 then if #parts >= 1 then
interval = tonumber(parts[1]) 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) table.remove(parts, 1)
end end
if #parts >= 1 then 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) table.remove(parts, 1)
end end
@ -46,13 +53,6 @@ worldedit.register_command("spiral2", {
return false, "Error: Unknown node '"..target_node_norm.."'." return false, "Error: Unknown node '"..target_node_norm.."'."
end 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 return true, mode, target_node_norm, interval, acceleration
end, end,
nodes_needed = function(name) nodes_needed = function(name)
@ -66,7 +66,12 @@ worldedit.register_command("spiral2", {
local success, count local success, count
if mode == "circle" then 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 else
success, count = wea.spiral_square( success, count = wea.spiral_square(
pos1, pos2, pos1, pos2,