//forest: use local wea alias

This commit is contained in:
Starbeamrainbowlabs 2022-01-02 17:17:05 +00:00
parent 80e230a9d7
commit 81773c8556
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -1,3 +1,5 @@
local wea = worldeditadditions
-- ███████ ██████ ██████ ███████ ███████ ████████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- █████ ██ ██ ██████ █████ ███████ ██
@ -17,12 +19,12 @@ worldedit.register_command("forest", {
params_text = params_text:sub(#match_start + 1) -- everything starts at 1 in Lua :-/
end
local success, sapling_list = worldeditadditions.parse.weighted_nodes(
worldeditadditions.split_shell(params_text),
local success, sapling_list = wea.parse.weighted_nodes(
wea.split_shell(params_text),
false,
function(name)
return worldedit.normalize_nodename(
worldeditadditions.normalise_saplingname(name)
wea.normalise_saplingname(name)
)
end
)
@ -35,22 +37,22 @@ worldedit.register_command("forest", {
return (pos2.x - pos1.x) * (pos2.y - pos1.y)
end,
func = function(name, density, sapling_list)
local start_time = worldeditadditions.get_ms_time()
local success, stats = worldeditadditions.forest(
local start_time = wea.get_ms_time()
local success, stats = wea.forest(
worldedit.pos1[name], worldedit.pos2[name],
density,
sapling_list
)
if not success then return success, stats end
local time_taken = worldeditadditions.format.human_time(worldeditadditions.get_ms_time() - start_time)
local time_taken = wea.format.human_time(wea.get_ms_time() - start_time)
local distribution_display = worldeditadditions.format.node_distribution(
local distribution_display = wea.format.node_distribution(
stats.placed,
stats.successes,
false -- no grand total at the bottom
)
minetest.log("action", name.." used //forest at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])..", "..stats.successes.." trees placed, averaging "..stats.attempts_avg.." growth attempts / tree and "..stats.failures.." failed attempts in "..time_taken)
minetest.log("action", name.." used //forest at "..wea.vector.tostring(worldedit.pos1[name]).." - "..wea.vector.tostring(worldedit.pos2[name])..", "..stats.successes.." trees placed, averaging "..stats.attempts_avg.." growth attempts / tree and "..stats.failures.." failed attempts in "..time_taken)
return true, distribution_display.."\n=========================\n"..stats.successes.." trees placed, averaging "..stats.attempts_avg.." growth attempts / tree and "..stats.failures.." failed attempts in "..time_taken
end
})