all commands: use human_time() in output

This commit is contained in:
Starbeamrainbowlabs 2020-06-26 21:23:03 +01:00
parent 3487e5c32b
commit 9b913bdfb1
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
12 changed files with 30 additions and 25 deletions

View file

@ -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()`)

View file

@ -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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -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 = "<replace_node> [<path_length> [<path_width> [<seed>]]]",
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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -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
})

View file

@ -1,8 +1,8 @@
-- ██████ ██ ██ ███████ █████ ██ █████ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ █████ ██████ ██ ███████ ████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ████ ███████ ██ ██ ███████ ██ ██ ██
-- ██ ██ █████ ██ ██ ███████
-- ██ ██ ██ ██ ██ ██ ██
-- ██ █ ██ ███████ ██ ██ ███████
-- ██ ███ ██ ██ ██ ██ ██ ██
-- ███ ███ ██ ██ ███████ ███████ ███████
worldedit.register_command("walls", {
params = "<replace_node>",
description = "Creates vertical walls of <replace_node> 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
})