diff --git a/CHANGELOG.md b/CHANGELOG.md index 1970e0c..ff8b26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ It's about time I started a changelog! This will serve from now on as the master ## v1.8 (unreleased) - Update `//multi` to display human readable times (e.g. `2.11mins` instead of `126600ms`) - Far wand: Notify player when setting pos1 and pos2 + - Make timings more accurate (use `minetest.get_us_time()` instead of `os.clock()`) diff --git a/worldeditadditions_commands/commands/bonemeal.lua b/worldeditadditions_commands/commands/bonemeal.lua index 2e3363e..5551cb7 100644 --- a/worldeditadditions_commands/commands/bonemeal.lua +++ b/worldeditadditions_commands/commands/bonemeal.lua @@ -54,8 +54,10 @@ worldedit.register_command("bonemeal", { end local percentage = worldeditadditions.round((nodes_bonemealed / candidates)*100, 2) local time_taken = worldeditadditions.get_ms_time() - start_time + -- Avoid nan% - since if there aren't any candidates then nodes_bonemealed will be 0 too + if candidates == 0 then percentage = 0 end minetest.log("action", name .. " used //bonemeal at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", bonemealing " .. nodes_bonemealed.." nodes (out of "..candidates.." nodes) at strength "..strength.." in "..time_taken.."s") - return true, nodes_bonemealed.." out of "..candidates.." (~"..percentage.."%) candidates bonemealed in "..time_taken.."s" + return true, nodes_bonemealed.." out of "..candidates.." (~"..percentage.."%) candidates bonemealed in "..worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/convolve.lua b/worldeditadditions_commands/commands/convolve.lua index 2ceae3d..a54979e 100644 --- a/worldeditadditions_commands/commands/convolve.lua +++ b/worldeditadditions_commands/commands/convolve.lua @@ -69,6 +69,6 @@ worldedit.register_command("convolve", { minetest.log("action", name.." used //convolve at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", adding "..stats.added.." nodes and removing "..stats.removed.." nodes in "..time_taken.."s") - return true, "Added "..stats.added.." and removed "..stats.removed.." nodes in " .. time_taken .. "s" + return true, "Added "..stats.added.." and removed "..stats.removed.." nodes in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/count.lua b/worldeditadditions_commands/commands/count.lua index 4a1699a..04b1861 100644 --- a/worldeditadditions_commands/commands/count.lua +++ b/worldeditadditions_commands/commands/count.lua @@ -27,7 +27,7 @@ worldedit.register_command("count", { local time_taken = worldeditadditions.get_ms_time() - start_time - minetest.log("action", name.." used //count at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", counting "..total.." nodes in "..time_taken.."s") + minetest.log("action", name.." used //count at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", counting "..total.." nodes in "..worldeditadditions.human_time(time_taken)) return true, result end }) diff --git a/worldeditadditions_commands/commands/ellipsoid.lua b/worldeditadditions_commands/commands/ellipsoid.lua index 602dedc..4bb1c51 100644 --- a/worldeditadditions_commands/commands/ellipsoid.lua +++ b/worldeditadditions_commands/commands/ellipsoid.lua @@ -48,7 +48,7 @@ worldedit.register_command("ellipsoid", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //ellipsoid at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) @@ -71,6 +71,6 @@ worldedit.register_command("hollowellipsoid", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //hollowellipsoid at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/floodfill.lua b/worldeditadditions_commands/commands/floodfill.lua index bd2caeb..4dc63e7 100644 --- a/worldeditadditions_commands/commands/floodfill.lua +++ b/worldeditadditions_commands/commands/floodfill.lua @@ -44,6 +44,6 @@ worldedit.register_command("floodfill", { end minetest.log("action", name .. " used //floodfill at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. nodes_replaced .. " nodes in " .. time_taken .. "s") - return true, nodes_replaced .. " nodes replaced in " .. time_taken .. "s" + return true, nodes_replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/layers.lua b/worldeditadditions_commands/commands/layers.lua index c275f08..ddef8c4 100644 --- a/worldeditadditions_commands/commands/layers.lua +++ b/worldeditadditions_commands/commands/layers.lua @@ -28,6 +28,6 @@ worldedit.register_command("layers", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //layers at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. changes.replaced .. " nodes and skipping " .. changes.skipped_columns .. " columns in " .. time_taken .. "s") - return true, changes.replaced .. " nodes replaced and " .. changes.skipped_columns .. " columns skipped in " .. time_taken .. "s" + return true, changes.replaced .. " nodes replaced and " .. changes.skipped_columns .. " columns skipped in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/maze.lua b/worldeditadditions_commands/commands/maze.lua index 2c86136..9e54b8e 100644 --- a/worldeditadditions_commands/commands/maze.lua +++ b/worldeditadditions_commands/commands/maze.lua @@ -1,11 +1,5 @@ local we_c = worldeditadditions_commands --- ███ ███ █████ ███████ ███████ --- ████ ████ ██ ██ ███ ██ --- ██ ████ ██ ███████ ███ █████ --- ██ ██ ██ ██ ██ ███ ██ --- ██ ██ ██ ██ ███████ ███████ - local function parse_params_maze(params_text, is_3d) if not params_text then return false, "No arguments specified" @@ -58,6 +52,14 @@ local function parse_params_maze(params_text, is_3d) return true, replace_node, seed, math.floor(path_length), math.floor(path_width), math.floor(path_depth) end + + +-- ███ ███ █████ ███████ ███████ +-- ████ ████ ██ ██ ███ ██ +-- ██ ████ ██ ███████ ███ █████ +-- ██ ██ ██ ██ ██ ███ ██ +-- ██ ██ ██ ██ ███████ ███████ + worldedit.register_command("maze", { params = " [ [ []]]", description = "Generates a maze covering the currently selected area (must be at least 3x3 on the x,z axes) with replace_node as the walls. Optionally takes a (integer) seed and the path length and width (see the documentation in the worldeditadditions README for more information).", @@ -77,7 +79,7 @@ worldedit.register_command("maze", { 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") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) @@ -108,6 +110,6 @@ worldedit.register_command("maze3d", { 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 " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/overlay.lua b/worldeditadditions_commands/commands/overlay.lua index 956c01c..a1e0c52 100644 --- a/worldeditadditions_commands/commands/overlay.lua +++ b/worldeditadditions_commands/commands/overlay.lua @@ -25,6 +25,6 @@ worldedit.register_command("overlay", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //overlay at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. changes.updated .. " nodes and skipping " .. changes.skipped_columns .. " columns in " .. time_taken .. "s") - return true, changes.updated .. " nodes replaced and " .. changes.skipped_columns .. " columns skipped in " .. time_taken .. "s" + return true, changes.updated .. " nodes replaced and " .. changes.skipped_columns .. " columns skipped in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/replacemix.lua b/worldeditadditions_commands/commands/replacemix.lua index 5a70bcb..83b22a2 100644 --- a/worldeditadditions_commands/commands/replacemix.lua +++ b/worldeditadditions_commands/commands/replacemix.lua @@ -88,6 +88,6 @@ worldedit.register_command("replacemix", { minetest.log("action", name .. " used //replacemix at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", replacing " .. changed.." nodes (out of "..nodes_total.." nodes) in "..time_taken.."s") - return true, distribution_table..changed.." out of "..candidates.." (~"..percentage_replaced.."%) candidates replaced in "..time_taken.."s" + return true, distribution_table..changed.." out of "..candidates.." (~"..percentage_replaced.."%) candidates replaced in "..worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/torus.lua b/worldeditadditions_commands/commands/torus.lua index 8294c36..021ac5a 100644 --- a/worldeditadditions_commands/commands/torus.lua +++ b/worldeditadditions_commands/commands/torus.lua @@ -46,7 +46,7 @@ worldedit.register_command("torus", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //torus at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) @@ -69,6 +69,6 @@ worldedit.register_command("hollowtorus", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //hollowtorus at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end }) diff --git a/worldeditadditions_commands/commands/walls.lua b/worldeditadditions_commands/commands/walls.lua index 14f2444..b67953d 100644 --- a/worldeditadditions_commands/commands/walls.lua +++ b/worldeditadditions_commands/commands/walls.lua @@ -1,8 +1,8 @@ --- ██████ ██ ██ ███████ ██████ ██ █████ ██ ██ --- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ --- ██ ██ ██ ██ █████ ██████ ██ ███████ ████ --- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ --- ██████ ████ ███████ ██ ██ ███████ ██ ██ ██ +-- ██ ██ █████ ██ ██ ███████ +-- ██ ██ ██ ██ ██ ██ ██ +-- ██ █ ██ ███████ ██ ██ ███████ +-- ██ ███ ██ ██ ██ ██ ██ ██ +-- ███ ███ ██ ██ ███████ ███████ ███████ worldedit.register_command("walls", { params = "", description = "Creates vertical walls of around the inside edges of the defined region.", @@ -29,6 +29,6 @@ worldedit.register_command("walls", { local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //walls from "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." to "..worldeditadditions.vector.tostring(worldedit.pos1[name])..", replacing " .. replaced .. " nodes in " .. time_taken .. "s") - return true, replaced .. " nodes replaced in " .. time_taken .. "s" + return true, replaced .. " nodes replaced in " .. worldeditadditions.human_time(time_taken) end })