//maze: update to use Vector3

This commit is contained in:
Starbeamrainbowlabs 2021-12-26 22:48:37 +00:00
parent b962ace8a8
commit af0e54cfdf
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -1,5 +1,6 @@
local wea = worldeditadditions local wea = worldeditadditions
local we_c = worldeditadditions_commands local we_c = worldeditadditions_commands
local Vector3 = worldeditadditions.Vector3
local function parse_params_maze(params_text, is_3d) local function parse_params_maze(params_text, is_3d)
if not params_text then params_text = "" end if not params_text then params_text = "" end
@ -74,12 +75,20 @@ worldedit.register_command("maze", {
return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name]) return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
end, end,
func = function(name, replace_node, seed, path_length, path_width) func = function(name, replace_node, seed, path_length, path_width)
local start_time = worldeditadditions.get_ms_time() local start_time = wea.get_ms_time()
local replaced = worldeditadditions.maze2d(worldedit.pos1[name], worldedit.pos2[name], replace_node, seed, path_length, path_width)
local time_taken = worldeditadditions.get_ms_time() - start_time
minetest.log("action", name .. " used //maze at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. " - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", replacing " .. replaced .. " nodes in " .. time_taken .. "s") local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
return true, replaced .. " nodes replaced in " .. worldeditadditions.format.human_time(time_taken) local replaced = wea.maze2d(
pos1, pos2,
replace_node,
seed,
path_length, path_width
)
local time_taken = wea.get_ms_time() - start_time
minetest.log("action", name.." used //maze at "..pos1.." - "..pos2..", replacing "..replaced.." nodes in "..time_taken.."s")
return true, replaced.." nodes replaced in "..wea.format.human_time(time_taken)
end end
}) })
@ -109,7 +118,7 @@ worldedit.register_command("maze3d", {
local time_taken = worldeditadditions.get_ms_time() - start_time local time_taken = worldeditadditions.get_ms_time() - start_time
minetest.log("action", name .. " used //maze3d at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. " - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", replacing " .. replaced .. " nodes in " .. time_taken .. "s") minetest.log("action", name.." used //maze3d at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", replacing "..replaced.." nodes in "..time_taken.."s")
return true, replaced .. " nodes replaced in " .. worldeditadditions.format.human_time(time_taken) return true, replaced.." nodes replaced in "..worldeditadditions.format.human_time(time_taken)
end end
}) })