From 6102a1adf58de9dc93e9bc7e9ec4277b38680f26 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 18 Sep 2022 22:37:26 +0100 Subject: [PATCH] Upgrade meta commands --- .../commands/meta/airapply.lua | 16 +++--- .../commands/meta/ellipsoidapply.lua | 18 +++--- .../commands/meta/for.lua | 14 ++--- .../commands/meta/init.lua | 16 +++--- .../commands/meta/macro.lua | 16 +++--- .../commands/meta/many.lua | 55 ++++++------------- .../commands/meta/multi.lua | 46 ++++------------ .../commands/meta/noiseapply2d.lua | 20 ++++--- .../commands/meta/subdivide.lua | 45 +++++++-------- 9 files changed, 105 insertions(+), 141 deletions(-) diff --git a/worldeditadditions_commands/commands/meta/airapply.lua b/worldeditadditions_commands/commands/meta/airapply.lua index 41585bf..da65a17 100644 --- a/worldeditadditions_commands/commands/meta/airapply.lua +++ b/worldeditadditions_commands/commands/meta/airapply.lua @@ -1,9 +1,11 @@ +local wea_c = worldeditadditions_core +local Vector3 = wea_c.Vector3 + -- █████ ██ ██████ █████ ██████ ██████ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ███████ ██ ██████ ███████ ██████ ██████ ██ ████ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██ -local wea_c = worldeditadditions_core worldeditadditions_core.register_command("airapply", { params = " ", @@ -30,7 +32,7 @@ worldeditadditions_core.register_command("airapply", { -- Run parsing of target command -- Lifted from cubeapply in WorldEdit - local args_parsed = {cmd_we.parse(args_text)} + local args_parsed = { cmd_we.parse(args_text) } if not table.remove(args_parsed, 1) then return false, args_parsed[1] end @@ -48,7 +50,7 @@ worldeditadditions_core.register_command("airapply", { return false, "Your privileges are insufficient to execute the command '"..cmd.."'." end - local pos1, pos2 = worldeditadditions.Vector3.sort( + local pos1, pos2 = Vector3.sort( worldedit.pos1[name], worldedit.pos2[name] ) @@ -57,15 +59,15 @@ worldeditadditions_core.register_command("airapply", { local success, stats_time = worldeditadditions.airapply( pos1, pos2, function() - cmd.func(name, worldeditadditions.table.unpack(args_parsed)) + cmd.func(name, table.unpack(args_parsed)) end ) if not success then return success, stats_time end - local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3) - local text_time_all = worldeditadditions.format.human_time(stats_time.all) - local text_time_fn = worldeditadditions.format.human_time(stats_time.fn) + local time_overhead = 100 - wea_c.round((stats_time.fn / stats_time.all) * 100, 3) + local text_time_all = wea_c.format.human_time(stats_time.all) + local text_time_fn = wea_c.format.human_time(stats_time.fn) minetest.log("action", name.." used //airapply at "..pos1.." - "..pos2.." in "..text_time_all) return true, "Complete in "..text_time_all.." ("..text_time_fn.." fn, "..time_overhead.."% airapply overhead)" diff --git a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua index 9ee94de..4110297 100644 --- a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua +++ b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua @@ -1,9 +1,12 @@ +local wea_c = worldeditadditions_core +local Vector3 = wea_c.Vector3 + + -- ███████ ██ ██ ██ ██████ ███████ ███████ █████ ██████ ██████ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- █████ ██ ██ ██ ██████ ███████ █████ ███████ ██████ ██████ ██ ████ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ███████ ███████ ███████ ██ ██ ███████ ███████ ██ ██ ██ ██ ███████ ██ -local wea_c = worldeditadditions_core worldeditadditions_core.register_command("ellipsoidapply", { params = " ", @@ -48,16 +51,17 @@ worldeditadditions_core.register_command("ellipsoidapply", { if not minetest.check_player_privs(name, cmd.privs) then return false, "Your privileges are insufficient to execute the command '"..cmd.."'." end - + local pos1 = Vector3.clone(worldedit.pos1[name]) + local pos2 = Vector3.clone(worldedit.pos2[name]) local success, stats_time = worldeditadditions.ellipsoidapply( - worldedit.pos1[name], worldedit.pos2[name], + pos1, pos2, function() - cmd.func(name, worldeditadditions.table.unpack(args_parsed)) + cmd.func(name, wea_c.table.unpack(args_parsed)) end --, args_parsed ) - local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3) + local time_overhead = 100 - wea_c.round((stats_time.fn / stats_time.all) * 100, 3) - minetest.log("action", name.." used //ellipsoidapply at "..worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name]).." in "..worldeditadditions.format.human_time(stats_time.all)) - return true, "Complete in "..worldeditadditions.format.human_time(stats_time.all).." ("..worldeditadditions.format.human_time(stats_time.fn).." fn, "..time_overhead.."% ellipsoidapply overhead)" + minetest.log("action", name.." used //ellipsoidapply at "..pos1.." - "..pos2.." in "..wea_c.format.human_time(stats_time.all)) + return true, "Complete in "..wea_c.format.human_time(stats_time.all).." ("..wea_c.format.human_time(stats_time.fn).." fn, "..time_overhead.."% ellipsoidapply overhead)" end }) diff --git a/worldeditadditions_commands/commands/meta/for.lua b/worldeditadditions_commands/commands/meta/for.lua index 5dff676..a13df7a 100644 --- a/worldeditadditions_commands/commands/meta/for.lua +++ b/worldeditadditions_commands/commands/meta/for.lua @@ -13,7 +13,7 @@ -- ?Basename support for values -- ?Comma deliniation support for values -local wea = worldeditadditions +local wea_c = worldeditadditions_core local function step(params) -- Initialize additional params on first call if not params.first then @@ -26,11 +26,11 @@ local function step(params) local v = params.values[params.i] -- Start a timer - local start_time = wea.get_ms_time() + local start_time = wea_c.get_ms_time() -- Execute command params.cmd.func(params.player_name, params.args:gsub("%%+",v)) -- Finish timer and add to total - params.time = params.time + wea.get_ms_time() - start_time + params.time = params.time + wea_c.get_ms_time() - start_time -- Increment iteration state params.i = params.i + 1 @@ -41,7 +41,7 @@ local function step(params) worldedit.player_notify(params.player_name, "For ".. table.concat(params.values,", ").. ", /"..params.cmd_name.." completed in " .. - wea.format.human_time(params.time)) + wea_c.format.human_time(params.time)) end end @@ -53,17 +53,17 @@ worldeditadditions_core.register_command("for", { if not params_text:match("%sdo%s") then return false, "Error: \"do\" argument is not present." end - local parts = wea.split(params_text,"%sdo%s") + local parts = wea_c.split(params_text,"%sdo%s") if not parts[1] == "" then return false, "Error: No values specified." end if not parts[2] then return false, "Error: No command specified." end - local values = wea.split(parts[1],"%s") + local values = wea_c.split(parts[1],"%s") local command, args = parts[2]:match("/([^%s]+)%s*(.*)$") if not args then args = "" - else args = wea.trim(args) end + else args = wea_c.trim(args) end return true, values, command, args end, diff --git a/worldeditadditions_commands/commands/meta/init.lua b/worldeditadditions_commands/commands/meta/init.lua index 7f0d43c..30924fb 100644 --- a/worldeditadditions_commands/commands/meta/init.lua +++ b/worldeditadditions_commands/commands/meta/init.lua @@ -6,13 +6,13 @@ -- Commands that work on other commands. -local we_cm = worldeditadditions_commands.modpath .. "/commands/meta/" +local we_cmdpath = worldeditadditions_commands.modpath .. "/commands/meta/" -dofile(we_cm.."airapply.lua") -dofile(we_cm.."ellipsoidapply.lua") -dofile(we_cm.."for.lua") +dofile(we_cmdpath.."airapply.lua") +dofile(we_cmdpath.."ellipsoidapply.lua") +dofile(we_cmdpath.."for.lua") -- dofile(we_cm.."macro.lua") -- Async bug -dofile(we_cm.."many.lua") -dofile(we_cm.."multi.lua") -dofile(we_cm.."noiseapply2d.lua") -dofile(we_cm.."subdivide.lua") +dofile(we_cmdpath.."many.lua") +dofile(we_cmdpath.."multi.lua") +dofile(we_cmdpath.."noiseapply2d.lua") +dofile(we_cmdpath.."subdivide.lua") diff --git a/worldeditadditions_commands/commands/meta/macro.lua b/worldeditadditions_commands/commands/meta/macro.lua index 92e9eaa..61011d4 100644 --- a/worldeditadditions_commands/commands/meta/macro.lua +++ b/worldeditadditions_commands/commands/meta/macro.lua @@ -4,7 +4,9 @@ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██████ ██ ██ ██████ local wea = worldeditadditions -local v3 = worldeditadditions.Vector3 +local wea_c = worldeditadditions +local v3 = wea_c.Vector3 + local function step(params) -- Initialize additional params on first call if not params.first then @@ -27,11 +29,11 @@ local function step(params) end -- Start a timer - local start_time = wea.get_ms_time() + local start_time = wea_c.get_ms_time() -- Execute command cmd.func(params.player_name, args) -- Finish timer and add to total - params.time = params.time + wea.get_ms_time() - start_time + params.time = params.time + wea_c.get_ms_time() - start_time -- Increment iteration state params.i = params.i + 1 @@ -41,7 +43,7 @@ local function step(params) else worldedit.player_notify(params.player_name, "The macro \"".. params.file.."\" was completed in " .. - wea.format.human_time(params.time)) + wea_c.format.human_time(params.time)) end end @@ -51,7 +53,7 @@ worldeditadditions_core.register_command("macro", { privs = {worldedit=true}, require_pos = 0, parse = function(params_text) - local parts = wea.split(params_text,"%s") + local parts = wea_c.split(params_text,"%s") local file_name, delay -- = params_text:match("^(.-)%s*(%d*%.?%d*)$") -- Check for params and delay if not parts[1] then @@ -72,7 +74,7 @@ worldeditadditions_core.register_command("macro", { end, func = function(name, file_name, delay) if not worldedit.pos1[name] then - worldedit.pos1[name] = v3.add(wea.player_vector(name), v3.new(0.5,-0.5,0.5)):floor() + worldedit.pos1[name] = v3.add(wea_c.player_vector(name), v3.new(0.5,-0.5,0.5)):floor() worldedit.mark_pos1(name) end worldedit.pos2[name] = worldedit.pos1[name] @@ -99,7 +101,7 @@ worldeditadditions_core.register_command("macro", { player_name = name, file = file_name:match("^[^%.]+"), delay = delay, - commands = wea.split(value,"[\n\r]+") + commands = wea_c.split(value,"[\n\r]+") }) end, diff --git a/worldeditadditions_commands/commands/meta/many.lua b/worldeditadditions_commands/commands/meta/many.lua index 49ecd05..7ae8b33 100644 --- a/worldeditadditions_commands/commands/meta/many.lua +++ b/worldeditadditions_commands/commands/meta/many.lua @@ -1,43 +1,20 @@ --- Executes multiple worldedit commands in sequence. --- @module worldeditadditions.multi +-- @module worldeditadditions_commands.multi + +local wea_c = worldeditadditions_core --- explode(separator, string) --- From http://lua-users.org/wiki/SplitJoin --- TODO: Refactor this to use wea.split instead -local function explode(delim, str) - local ll, is_done - local delim_length = string.len(delim) - ll = 0 - is_done = false - - return function() - if is_done then return end - - local result - local loc = string.find(str, delim, ll, true) -- find the next d in the string - if loc ~= nil then -- if "not not" found then.. - result = string.sub(str, ll, loc - 1) -- Save it in our array. - ll = loc + delim_length -- save just after where we found it for searching next time. - else - result = string.sub(str, ll) -- Save what's left in our array. - is_done = true - end - - return result - end -end local function step(params) - local start_time = worldeditadditions.get_ms_time() + local start_time = wea_c.get_ms_time() local full_cmd = params.cmd_name.." "..params.args worldedit.player_notify(params.name, string.format("[ many | /%s ] %d / %d (~%.2f%%) complete | last: %s, average: %s, ETA: ~%s", full_cmd, (params.i + 1), params.count, ((params.i + 1) / params.count)*100, - worldeditadditions.format.human_time(params.times[#params.times] or 0), - worldeditadditions.format.human_time(worldeditadditions.average(params.times)), - worldeditadditions.format.human_time(worldeditadditions.eta( + wea_c.format.human_time(params.times[#params.times] or 0), + wea_c.format.human_time(wea_c.average(params.times)), + wea_c.format.human_time(wea_c.eta( params.times, params.i, params.count @@ -50,20 +27,20 @@ local function step(params) cmd.func(params.name, params.args) - table.insert(params.times, worldeditadditions.get_ms_time() - start_time) + table.insert(params.times, wea_c.get_ms_time() - start_time) params.i = params.i + 1 if params.i < params.count then minetest.after(0, step, params) else - local total_time = (worldeditadditions.get_ms_time() - params.master_start_time) + local total_time = (wea_c.get_ms_time() - params.master_start_time) local done_message = {} table.insert(done_message, string.format("Executed '"..full_cmd.."' %d times in %s (~%s / time)", #params.times, - worldeditadditions.format.human_time(total_time), - worldeditadditions.format.human_time( - worldeditadditions.average(params.times) + wea_c.format.human_time(total_time), + wea_c.format.human_time( + wea_c.average(params.times) ) ) ) @@ -71,7 +48,7 @@ local function step(params) if #params.times < 10 then local message_parts = {} for j=1,#params.times do - table.insert(message_parts, worldeditadditions.format.human_time(params.times[j])) + table.insert(message_parts, wea_c.format.human_time(params.times[j])) end table.insert(done_message, "; ") table.insert(done_message, table.concat(message_parts, ", ")) @@ -88,7 +65,7 @@ minetest.register_chatcommand("/many", { func = function(name, params_text) local i = 1 -- For feedback only - local master_start_time = worldeditadditions.get_ms_time() + local master_start_time = wea_c.get_ms_time() local times = {} local count, cmd_name, args = params_text:match("^(%d+)%s([^%s]+)%s(.+)$") @@ -97,11 +74,11 @@ minetest.register_chatcommand("/many", { if not count then return false, "Error: Invalid syntax" end end if not args then args = "" end - args = worldeditadditions.trim(args) + args = wea_c.trim(args) -- print("[many] count", count, "cmd_name", cmd_name, "args", args) count = tonumber(count) - cmd_name = worldeditadditions.trim(cmd_name):sub(2) -- Things start at 1, not 0 in Lua :-( + cmd_name = wea_c.trim(cmd_name):sub(2) -- Things start at 1, not 0 in Lua :-( -- Check the command we're going to execute local cmd = minetest.chatcommands[cmd_name] diff --git a/worldeditadditions_commands/commands/meta/multi.lua b/worldeditadditions_commands/commands/meta/multi.lua index 34d26c0..f448685 100644 --- a/worldeditadditions_commands/commands/meta/multi.lua +++ b/worldeditadditions_commands/commands/meta/multi.lua @@ -1,30 +1,6 @@ --- Executes multiple worldedit commands in sequence. --- @module worldeditadditions.multi - --- explode(separator, string) --- From http://lua-users.org/wiki/SplitJoin -local function explode(delim, str) - local ll, is_done - local delim_length = string.len(delim) - ll = 0 - is_done = false - - return function() - if is_done then return end - - local result - local loc = string.find(str, delim, ll, true) -- find the next d in the string - if loc ~= nil then -- if "not not" found then.. - result = string.sub(str, ll, loc - 1) -- Save it in our array. - ll = loc + delim_length -- save just after where we found it for searching next time. - else - result = string.sub(str, ll) -- Save what's left in our array. - is_done = true - end - - return result - end -end +-- @module worldeditadditions_commands.multi +local wea_c = worldeditadditions_core minetest.register_chatcommand("/multi", { params = "/ // / .....", @@ -32,24 +8,24 @@ minetest.register_chatcommand("/multi", { privs = { worldedit = true }, func = function(name, params_text) if not params_text then return false, "Error: No commands specified, so there's nothing to do." end - params_text = worldeditadditions.trim(params_text) + params_text = wea_c.trim(params_text) if #params_text == 0 then return false, "Error: No commands specified, so there's nothing to do." end - local master_start_time = worldeditadditions.get_ms_time() + local master_start_time = wea_c.get_ms_time() local times = {} -- Tokenise the input into a list of commands - local success, commands = worldeditadditions.parse.tokenise_commands(params_text) + local success, commands = wea_c.parse.tokenise_commands(params_text) if not success then return success, commands end for i, command in ipairs(commands) do -- print("[DEBUG] i", i, "command: '"..command.."'") - local start_time = worldeditadditions.get_ms_time() + local start_time = wea_c.get_ms_time() local found, _, command_name, args = command:find("^([^%s]+)%s(.+)$") if not found then command_name = command end -- Things start at 1, not 0 in Lua :-( - command_name = worldeditadditions.trim(command_name):sub(2) -- Strip the leading / + command_name = wea_c.trim(command_name):sub(2) -- Strip the leading / if not args then args = "" end -- print("command_name", command_name) @@ -66,21 +42,21 @@ minetest.register_chatcommand("/multi", { minetest.log("action", name.." runs "..command) cmd.func(name, args) - times[#times + 1] = (worldeditadditions.get_ms_time() - start_time) + times[#times + 1] = (wea_c.get_ms_time() - start_time) -- i = i + 1 end - local total_time = (worldeditadditions.get_ms_time() - master_start_time) + local total_time = (wea_c.get_ms_time() - master_start_time) local done_message = {} table.insert(done_message, string.format("Executed %d commands in %s (", #times, - worldeditadditions.format.human_time(total_time) + wea_c.format.human_time(total_time) ) ) local message_parts = {} for j=1,#times do - table.insert(message_parts, worldeditadditions.format.human_time(times[j])) + table.insert(message_parts, wea_c.format.human_time(times[j])) end table.insert(done_message, table.concat(message_parts, ", ")) table.insert(done_message, ")") diff --git a/worldeditadditions_commands/commands/meta/noiseapply2d.lua b/worldeditadditions_commands/commands/meta/noiseapply2d.lua index bd31ada..6ec5799 100644 --- a/worldeditadditions_commands/commands/meta/noiseapply2d.lua +++ b/worldeditadditions_commands/commands/meta/noiseapply2d.lua @@ -1,10 +1,12 @@ +local wea_c = worldeditadditions_core +local Vector3 = wea_c.Vector3 + + -- ███ ██ ██████ ██ ███████ ███████ █████ ██████ ██████ ██ ██ ██ ██████ ██████ -- ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ███████ █████ ███████ ██████ ██████ ██ ████ █████ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ████ ██████ ██ ███████ ███████ ██ ██ ██ ██ ███████ ██ ███████ ██████ -local wea_c = worldeditadditions_core - worldeditadditions_core.register_command("noiseapply2d", { params = " ", @@ -30,7 +32,7 @@ worldeditadditions_core.register_command("noiseapply2d", { -- Run parsing of target command -- Lifted from cubeapply in WorldEdit - local args_parsed = {cmd_we.parse(args_text)} + local args_parsed = { cmd_we.parse(args_text) } if not table.remove(args_parsed, 1) then return false, args_parsed[1] end @@ -60,7 +62,7 @@ worldeditadditions_core.register_command("noiseapply2d", { return false, "Your privileges are insufficient to execute the command '"..cmd.."'." end - local pos1, pos2 = worldeditadditions.Vector3.sort( + local pos1, pos2 = Vector3.sort( worldedit.pos1[name], worldedit.pos2[name] ) @@ -69,18 +71,18 @@ worldeditadditions_core.register_command("noiseapply2d", { local success, stats_time = worldeditadditions.noiseapply2d( pos1, pos2, threshold, - worldeditadditions.Vector3.new( + Vector3.new( scale, scale, scale ), function() - cmd.func(name, worldeditadditions.table.unpack(args_parsed)) + cmd.func(name, wea_c.table.unpack(args_parsed)) end ) if not success then return success, stats_time end - local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3) - local text_time_all = worldeditadditions.format.human_time(stats_time.all) - local text_time_fn = worldeditadditions.format.human_time(stats_time.fn) + local time_overhead = 100 - wea_c.round((stats_time.fn / stats_time.all) * 100, 3) + local text_time_all = wea_c.format.human_time(stats_time.all) + local text_time_fn = wea_c.format.human_time(stats_time.fn) minetest.log("action", name.." used //noiseapply2d at "..pos1.." - "..pos2.." in "..text_time_all) return true, "Complete in "..text_time_all.." ("..text_time_fn.." fn, "..time_overhead.."% noiseapply2d overhead)" diff --git a/worldeditadditions_commands/commands/meta/subdivide.lua b/worldeditadditions_commands/commands/meta/subdivide.lua index 724a8da..e027455 100644 --- a/worldeditadditions_commands/commands/meta/subdivide.lua +++ b/worldeditadditions_commands/commands/meta/subdivide.lua @@ -1,5 +1,6 @@ local wea = worldeditadditions local wea_c = worldeditadditions_core +local Vector3 = wea_c.Vector3 -- Test command: -- //multi //fp set1 1330 60 5455 //fp set2 1355 35 5430 //subdivide 10 10 10 fixlight //y @@ -14,7 +15,7 @@ local function will_trigger_saferegion(name, cmd_name, args) if not parse_success then return nil, table.remove(parsed, 1) end if not def.nodes_needed then return false end - local result = def.nodes_needed(name, wea.table.unpack(parsed)) + local result = def.nodes_needed(name, wea_c.table.unpack(parsed)) if not result then return nil, result end if result > 10000 then return true end return false @@ -36,7 +37,7 @@ worldeditadditions_core.register_command("subdivide", { privs = { worldedit = true }, require_pos = 2, parse = function(params_text) - local parts = wea.split(params_text, "%s+", false) + local parts = wea_c.split(params_text, "%s+", false) if #parts < 4 then return false, "Error: Not enough arguments (try /help /subdivide)." @@ -69,9 +70,9 @@ worldeditadditions_core.register_command("subdivide", { return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name]) end, func = function(name, chunk_size, cmd_name, args) - local time_total = wea.get_ms_time() + local time_total = wea_c.get_ms_time() - local pos1, pos2 = worldedit.sort_pos(worldedit.pos1[name], worldedit.pos2[name]) + local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name]) local volume = worldedit.volume(pos1, pos2) local cmd = wea_c.fetch_command_def(cmd_name) @@ -88,8 +89,8 @@ worldeditadditions_core.register_command("subdivide", { -- * math.ceil((pos2.y - pos1.y) / (chunk_size.y - 1)) -- * math.ceil((pos2.z - pos1.z) / (chunk_size.z - 1)) - local msg_prefix = "[ subdivide | "..wea.trim(table.concat({cmd_name, args}, " ")).." ] " - local time_last_msg = wea.get_ms_time() + local msg_prefix = "[ subdivide | "..wea_c.trim(table.concat({cmd_name, args}, " ")).." ] " + local time_last_msg = wea_c.get_ms_time() local cmd_args_parsed = {cmd.parse(args)} local success = table.remove(cmd_args_parsed, 1) @@ -100,15 +101,15 @@ worldeditadditions_core.register_command("subdivide", { wea.subdivide(pos1, pos2, chunk_size, function(cpos1, cpos2, stats) -- Called on every subblock if stats.chunks_completed == 1 then - local chunk_size_display = { - x = stats.chunk_size.x + 1, - y = stats.chunk_size.y + 1, - z = stats.chunk_size.z + 1 - } + local chunk_size_display = Vector3.new( + stats.chunk_size.x + 1, -- x + stats.chunk_size.y + 1, -- y + stats.chunk_size.z + 1 -- z + ) worldedit.player_notify(name, string.format( "%sStarting - chunk size: %s, %d chunks total (%d nodes)", msg_prefix, - wea.vector.tostring(chunk_size_display), + tostring(chunk_size_display), stats.chunks_total, stats.volume_nodes )) @@ -118,26 +119,26 @@ worldeditadditions_core.register_command("subdivide", { worldedit.pos1[name] = cpos1 worldedit.pos2[name] = cpos2 worldedit.marker_update(name) - cmd.func(name, wea.table.unpack(cmd_args_parsed)) + cmd.func(name, wea_c.table.unpack(cmd_args_parsed)) if will_trigger_saferegion(name, cmd_name, args) then minetest.chatcommands["/y"].func(name) end worldedit.player_notify_unsuppress(name) -- Send updates every 2 seconds, and after the first 3 chunks are done - if worldeditadditions.get_ms_time() - time_last_msg > 2 * 1000 or stats.chunks_completed == 3 or stats.chunks_completed == stats.chunks_total then + if wea_c.get_ms_time() - time_last_msg > 2 * 1000 or stats.chunks_completed == 3 or stats.chunks_completed == stats.chunks_total then worldedit.player_notify(name, string.format("%s%d / %d (~%.2f%%) complete | last chunk: %s, average: %s, %.2f%% emerge overhead, ETA: ~%s", msg_prefix, stats.chunks_completed, stats.chunks_total, (stats.chunks_completed / stats.chunks_total) * 100, - worldeditadditions.format.human_time(math.floor(stats.times.step_last)), -- the time is an integer anyway because precision - worldeditadditions.format.human_time(wea.average(stats.times.steps)), + wea_c.format.human_time(math.floor(stats.times.step_last)), -- the time is an integer anyway because precision + wea_c.format.human_time(wea_c.average(stats.times.steps)), stats.emerge_overhead * 100, - worldeditadditions.format.human_time(stats.eta) + wea_c.format.human_time(stats.eta) ) ) - time_last_msg = wea.get_ms_time() + time_last_msg = wea_c.get_ms_time() end end, function(_, _, stats) worldedit.pos1[name] = pos1 @@ -147,17 +148,17 @@ worldeditadditions_core.register_command("subdivide", { -- Called on completion minetest.log("action", string.format("%s used //subdivide at %s - %s, with %d chunks and %d total nodes in %s", name, - wea.vector.tostring(pos1), - wea.vector.tostring(pos2), + tostring(pos1), + tostring(pos2), stats.chunks_completed, stats.volume_nodes, - worldeditadditions.format.human_time(stats.times.total) + wea_c.format.human_time(stats.times.total) )) worldedit.player_notify(name, string.format( "%sComplete: %d chunks processed in %s (%.2f%% emerge overhead, emerge totals: %s)", msg_prefix, stats.chunks_completed, - worldeditadditions.format.human_time(stats.times.total), + wea_c.format.human_time(stats.times.total), stats.emerge_overhead * 100, emerge_stats_tostring(stats.emerge) ))