mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-22 19:45:02 +00:00
//spiral2: fix bugs
This commit is contained in:
parent
dae59b63db
commit
e610eb7a92
1 changed files with 16 additions and 11 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue