Minetest-WorldEditAdditions/worldeditadditions_commands/commands/measure/msize.lua

30 lines
1 KiB
Lua
Raw Permalink Normal View History

2022-09-18 21:46:20 +00:00
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
2021-07-03 03:10:03 +00:00
-- ███ ███ ███████ ██ ███████ ███████
-- ████ ████ ██ ██ ███ ██
-- ██ ████ ██ ███████ ██ ███ █████
-- ██ ██ ██ ██ ██ ███ ██
-- ██ ██ ███████ ██ ███████ ███████
2022-09-18 21:46:20 +00:00
worldeditadditions_core.register_command("msize", {
2021-07-03 03:10:03 +00:00
params = "",
description = "Return the length of each axis of current selection.",
privs = { worldedit = true },
require_pos = 2,
parse = function(params_text)
return true
end,
func = function(name, params_text)
local str = "The dimensions of the current selection are "
2022-09-18 21:46:20 +00:00
2024-10-07 22:40:34 +00:00
local pos1 = Vector3.clone(wea_c.pos.get(name, 1))
local pos2 = Vector3.clone(wea_c.pos.get(name, 2))
2022-09-18 21:46:20 +00:00
local vec = (pos2 - pos1):abs()
2021-07-03 03:10:03 +00:00
2021-07-13 16:08:56 +00:00
return true, str .. "x: " .. vec.x .. ", y: " .. vec.y .. ", z: " .. vec.z
2021-07-03 03:10:03 +00:00
end,
})