Upgrade the last of the commands o/

This commit is contained in:
Starbeamrainbowlabs 2022-09-18 22:46:20 +01:00
parent 6102a1adf5
commit 21c5b9d483
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
7 changed files with 50 additions and 23 deletions

View file

@ -1,3 +1,5 @@
local wea_c = worldeditadditions_core
-- ███████ █████ ██████ ██ ██ ███ ██ ██████ █████ ██ ██ █████ ███████ ███████ ███████
-- ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██████ ██ ██ ██ ██ ██ ██ ███ ███████ ██ ██ ███████ ███████ █████ ███████
@ -17,15 +19,15 @@ minetest.register_chatcommand("/saplingaliases", {
if params_text == "aliases" then
table.insert(msg, "Currently registered aliases:\n")
local aliases = worldeditadditions.get_all_sapling_aliases()
local aliases = wea_c.get_all_sapling_aliases()
local display = {}
for node_name, alias in pairs(aliases) do
table.insert(display, { node_name, alias })
end
table.sort(display, function(a, b) return a[2] < b[2] end)
table.insert(msg, worldeditadditions.format.make_ascii_table(display))
table.insert(msg, wea_c.format.make_ascii_table(display))
elseif params_text == "all_saplings" then
local results = worldeditadditions.registered_nodes_by_group("sapling")
local results = wea_c.registered_nodes_by_group("sapling")
table.insert(msg, "Sapling-like nodes:\n")
local str = table.concat(results, "\n")
table.insert(msg, str)

View file

@ -1,4 +1,5 @@
local wea = worldeditadditions
local wea_c = worldeditadditions_core
-- ███████ ██████ ██ ██ ██ ██████ ████████ ██ ██ ███████ ████████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
@ -12,7 +13,7 @@ minetest.register_chatcommand("/sculptlist", {
func = function(name, params_text)
if name == nil then return end
if not params_text then params_text = "" end
params_text = wea.trim(params_text)
params_text = wea_c.trim(params_text)
local msg = {}
@ -49,7 +50,7 @@ minetest.register_chatcommand("/sculptlist", {
-- Sort by brush name
table.sort(display, function(a, b) return a[1] < b[1] end)
table.insert(msg, worldeditadditions.format.make_ascii_table(display))
table.insert(msg, wea_c.format.make_ascii_table(display))
end
worldedit.player_notify(name, table.concat(msg))

View file

@ -6,9 +6,9 @@
-- Chat commands that measure things.
local we_cm = worldeditadditions_commands.modpath .. "/commands/measure/"
local subpath = worldeditadditions_commands.modpath .. "/commands/measure/"
dofile(we_cm.."mface.lua")
dofile(we_cm.."midpos.lua")
dofile(we_cm.."msize.lua")
dofile(we_cm.."mtrig.lua")
dofile(subpath.."mface.lua")
dofile(subpath.."midpos.lua")
dofile(subpath.."msize.lua")
dofile(subpath.."mtrig.lua")

View file

@ -3,7 +3,7 @@
-- ██ ████ ██ █████ ███████ ██ █████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██████ ███████
local wea = worldeditadditions
worldeditadditions_core.register_command("mface", {
params = "",
description = "Return player facing axis.",

View file

@ -1,9 +1,12 @@
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
-- ███ ███ ██ ██████ ██████ ██████ ███████
-- ████ ████ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ████ ██ ██ ██ ██ ██████ ██ ██ ███████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██████ ██ ██████ ███████
local wea = worldeditadditions
worldeditadditions_core.register_command("midpos", {
params = "",
description = "Return the mid point of current selection.",
@ -14,8 +17,13 @@ worldeditadditions_core.register_command("midpos", {
end,
func = function(name, params_text)
local str = "The centre of the current selection is at "
local vec = wea.vector.mean(worldedit.pos1[name],worldedit.pos2[name])
return true, str .. wea.table.tostring(vec)
local pos1 = Vector3.new(worldedit.pos1[name])
local pos2 = Vector3.new(worldedit.pos2[name])
local vec = wea_c.vector.mean(pos1, pos2)
return true, str .. wea_c.table.tostring(vec)
end,
})

View file

@ -1,9 +1,13 @@
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
-- ███ ███ ███████ ██ ███████ ███████
-- ████ ████ ██ ██ ███ ██
-- ██ ████ ██ ███████ ██ ███ █████
-- ██ ██ ██ ██ ██ ███ ██
-- ██ ██ ███████ ██ ███████ ███████
local wea = worldeditadditions
worldeditadditions_core.register_command("msize", {
params = "",
description = "Return the length of each axis of current selection.",
@ -14,8 +18,11 @@ worldeditadditions_core.register_command("msize", {
end,
func = function(name, params_text)
local str = "The dimensions of the current selection are "
local vec = vector.subtract(worldedit.pos2[name],worldedit.pos1[name])
wea.vector.abs(vec)
local pos1 = Vector3.new(worldedit.pos1[name])
local pos2 = Vector3.new(worldedit.pos2[name])
local vec = (pos2 - pos1):abs()
return true, str .. "x: " .. vec.x .. ", y: " .. vec.y .. ", z: " .. vec.z
end,

View file

@ -1,10 +1,13 @@
local wea_c = worldeditadditions_core
local v3 = wea_c.Vector3
-- ███ ███ ████████ ██████ ██ ██████
-- ████ ████ ██ ██ ██ ██ ██
-- ██ ████ ██ ██ ██████ ██ ██ ███
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██████
local wea = worldeditadditions
local v3 = worldeditadditions.Vector3
worldeditadditions_core.register_command("mtrig", {
params = "",
description = "Return the length of and angles of an imginary line between pos1 and pos2 in the selection.",
@ -15,11 +18,17 @@ worldeditadditions_core.register_command("mtrig", {
end,
func = function(name, params_text)
local str = "The measurements of the line from pos1 to pos2 are Length (D): "
local vec = v3.subtract(worldedit.pos2[name],worldedit.pos1[name]):abs()
local pos1 = v3.new(worldedit.pos2[name])
local pos2 = v3.new(worldedit.pos1[name])
local vec = (pos2 - pos1):abs()
local len = vec:length()
str = str..wea.round(len, 4)..", ∠XZ: "..
wea.round(math.deg(math.atan(vec.z/vec.x)), 4).."°, ∠DY: "..
wea.round(math.deg(math.asin(vec.y/len)), 4).."°"
str = str..wea_c.round(len, 4)..", ∠XZ: "..
wea_c.round(math.deg(math.atan(vec.z/vec.x)), 4).."°, ∠DY: "..
wea_c.round(math.deg(math.asin(vec.y/len)), 4).."°"
return true, str
end,
})