next batch of upgraded commands

This commit is contained in:
Starbeamrainbowlabs 2022-09-18 21:39:48 +01:00
parent 459e15b5c2
commit c3e8df3a9e
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
5 changed files with 61 additions and 19 deletions

@ -69,11 +69,11 @@ worldeditadditions_core.register_command("bonemeal", {
if not success then return success, nodes_bonemealed end if not success then return success, nodes_bonemealed end
local percentage = wea_c.round((nodes_bonemealed / candidates)*100, 2) local percentage = wea_c.round((nodes_bonemealed / candidates)*100, 2)
local time_taken = wea_c.get_ms_time() - start_time local time_taken = wea_c.format.human_time(wea_c.get_ms_time() - start_time)
-- Avoid nan% - since if there aren't any candidates then nodes_bonemealed will be 0 too -- Avoid nan% - since if there aren't any candidates then nodes_bonemealed will be 0 too
if candidates == 0 then percentage = 0 end if candidates == 0 then percentage = 0 end
minetest.log("action", name .. " used //bonemeal at "..pos1.." - "..pos2..", bonemealing " .. nodes_bonemealed.." nodes (out of "..candidates.." nodes) at strength "..strength.." in "..time_taken.."s") minetest.log("action", name .. " used //bonemeal at "..pos1.." - "..pos2..", bonemealing " .. nodes_bonemealed.." nodes (out of "..candidates.." nodes) at strength "..strength.." in "..time_taken)
return true, nodes_bonemealed.." out of "..candidates.." (~"..percentage.."%) candidates bonemealed in "..wea_c.format.human_time(time_taken) return true, nodes_bonemealed.." out of "..candidates.." (~"..percentage.."%) candidates bonemealed in "..time_taken
end end
}) })

@ -6,8 +6,8 @@
-- 2d and 3d outlines of shapes. -- 2d and 3d outlines of shapes.
local we_cm = worldeditadditions_commands.modpath .. "/commands/wireframe/" local wea_cmd = worldeditadditions_commands.modpath .. "/commands/wireframe/"
dofile(we_cm.."wbox.lua") dofile(wea_cmd.."wbox.lua")
dofile(we_cm.."wcompass.lua") dofile(wea_cmd.."wcompass.lua")
dofile(we_cm.."wcorner.lua") dofile(wea_cmd.."wcorner.lua")

@ -1,10 +1,14 @@
local wea = worldeditadditions
local wea_c = worldeditadditions
local Vector3 = worldeditadditions.Vector3
-- ██ ██ ██████ ██████ ██ ██ -- ██ ██ ██████ ██████ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ██
-- ██ █ ██ ██████ ██ ██ ███ -- ██ █ ██ ██████ ██ ██ ███
-- ██ ███ ██ ██ ██ ██ ██ ██ ██ -- ██ ███ ██ ██ ██ ██ ██ ██ ██
-- ███ ███ ██████ ██████ ██ ██ -- ███ ███ ██████ ██████ ██ ██
local wea = worldeditadditions
local v3 = worldeditadditions.Vector3
worldeditadditions_core.register_command("wbox", { worldeditadditions_core.register_command("wbox", {
params = "<replace_node>", params = "<replace_node>",
description = "Sets the edges of the current selection to <replace_node>", description = "Sets the edges of the current selection to <replace_node>",
@ -21,7 +25,7 @@ worldeditadditions_core.register_command("wbox", {
return true, node return true, node
end, end,
nodes_needed = function(name) nodes_needed = function(name)
local delta = v3.subtract(worldedit.pos2[name], worldedit.pos1[name]):abs():add(1) local delta = Vector3.subtract(worldedit.pos2[name], worldedit.pos1[name]):abs():add(1)
local total, mult, axes = 1, 4, {"x","y","z"} local total, mult, axes = 1, 4, {"x","y","z"}
for k,v in pairs(axes) do for k,v in pairs(axes) do
if worldedit.pos1[name] ~= worldedit.pos2[name] then total = total*2 if worldedit.pos1[name] ~= worldedit.pos2[name] then total = total*2
@ -33,7 +37,16 @@ worldeditadditions_core.register_command("wbox", {
return total return total
end, end,
func = function(name, node) func = function(name, node)
local _, count = wea.wire_box(worldedit.pos1[name], worldedit.pos2[name], node) local start_time = wea_c.get_ms_time()
return _, count .. " nodes set"
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
local success, count = wea.wire_box(pos1, pos2, node)
if not success then return success, count end
local time_taken = wea_c.format.human_time(wea_c.get_ms_time() - start_time)
minetest.log("action", name.." used //wbox at "..pos1.." - "..pos2..", taking "..time_taken)
return true, count .. " nodes set in "..time_taken
end, end,
}) })

@ -1,16 +1,20 @@
local wea = worldeditadditions
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
-- ██ ██ ██████ ██████ ███ ███ ██████ █████ ███████ ███████ -- ██ ██ ██████ ██████ ███ ███ ██████ █████ ███████ ███████
-- ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██
-- ██ █ ██ ██ ██ ██ ██ ████ ██ ██████ ███████ ███████ ███████ -- ██ █ ██ ██ ██ ██ ██ ████ ██ ██████ ███████ ███████ ███████
-- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███ ███ ██████ ██████ ██ ██ ██ ██ ██ ███████ ███████ -- ███ ███ ██████ ██████ ██ ██ ██ ██ ██ ███████ ███████
local wea = worldeditadditions
worldeditadditions_core.register_command("wcompass", { worldeditadditions_core.register_command("wcompass", {
params = "<replace_node> [<bead_node>]", params = "<replace_node> [<bead_node>]",
description = "Creates a compass around pos1 with a single node bead pointing north (+Z).", description = "Creates a compass around pos1 with a single node bead pointing north (+Z).",
privs = {worldedit=true}, privs = {worldedit=true},
require_pos = 1, require_pos = 1,
parse = function(params_text) parse = function(params_text)
local parts = wea.split(params_text," ",true) local parts = wea_c.split(params_text," ",true)
if not parts[1] then if not parts[1] then
return false, "Error: too few arguments! Expected: \"<replace_node> [<bead_node>]\"" return false, "Error: too few arguments! Expected: \"<replace_node> [<bead_node>]\""
elseif not parts[2] then elseif not parts[2] then
@ -29,7 +33,17 @@ worldeditadditions_core.register_command("wcompass", {
return 26 return 26
end, end,
func = function(name, node1, node2) func = function(name, node1, node2)
local _, count = wea.make_compass(worldedit.pos1[name], node1, node2) local start_time = wea_c.get_ms_time()
return _, count .. " nodes set"
local pos1 = Vector3.clone(worldedit.pos1[name])
local success, count = wea.make_compass(pos1, node1, node2)
if not success then return success, count end
local time_taken = wea_c.format.human_time(wea_c.get_ms_time() - start_time)
minetest.log("action", name.." used //wcompass at "..pos1..", taking "..time_taken)
return true, count .. " nodes set in "..time_taken
end, end,
}) })

@ -1,9 +1,13 @@
local wea_c = worldeditadditions
local wea = worldeditadditions
local Vector3 = wea_c.Vector3
-- ██ ██ ██████ ██████ ██████ ███ ██ ███████ ██████ -- ██ ██ ██████ ██████ ██████ ███ ██ ███████ ██████
-- ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██
-- ██ █ ██ ██ ██ ██ ██████ ██ ██ ██ █████ ██████ -- ██ █ ██ ██ ██ ██ ██████ ██ ██ ██ █████ ██████
-- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███ ███ ██████ ██████ ██ ██ ██ ████ ███████ ██ ██ -- ███ ███ ██████ ██████ ██ ██ ██ ████ ███████ ██ ██
local wea = worldeditadditions
worldeditadditions_core.register_command("wcorner", { worldeditadditions_core.register_command("wcorner", {
params = "<replace_node>", params = "<replace_node>",
description = "Set the corners of the current selection to <replace_node>", description = "Set the corners of the current selection to <replace_node>",
@ -24,7 +28,18 @@ worldeditadditions_core.register_command("wcorner", {
return total return total
end, end,
func = function(name, node) func = function(name, node)
local _, count = wea.corner_set(worldedit.pos1[name], worldedit.pos2[name], node)
return _, count .. " nodes set" local start_time = wea_c.get_ms_time()
local pos1, pos2 = Vector3.sort(worldedit.pos1[name], worldedit.pos2[name])
local success, count = wea.corner_set(pos1, pos2, node)
if not success then return success, count end
local time_taken = wea_c.format.human_time(wea_c.get_ms_time() - start_time)
minetest.log("action", name.." used //wcorner at "..pos1.." - "..pos2..", taking "..time_taken)
return true, count .. " nodes set in "..time_taken
end, end,
}) })