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

30 lines
1.2 KiB
Lua
Raw Normal View History

2021-07-09 03:54:05 +00:00
-- ███ ███ ██████ ████████ ██ ██████
-- ████ ████ ██ ██ ██ ██ ██
-- ██ ████ ██ ██████ ██ ██ ██ ███
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██████
local wea = worldeditadditions
2021-07-09 04:04:51 +00:00
-- worldeditdebug.register("abschk")
2021-07-09 03:54:05 +00:00
worldedit.register_command("mtrig", {
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 measurements of the line pos1,pos2 are Length: "
local vec = vector.subtract(worldedit.pos2[name],worldedit.pos1[name])
wea.vector.abs(vec)
-- Test:
2021-07-09 04:04:51 +00:00
-- if worldeditdebug.debug["abschk"][name] then
-- -- //debug abschk
-- return false, "Values = " .. worldeditdebug.table_tostring(vec)
-- end
2021-07-09 03:54:05 +00:00
local len = wea.Vector3.length(vec)
str = str..len..", X/Z angle: "..math.atan(vec.z/vec.x).."° h/Y angle: "..math.atan(vec.y/len).."°"
return true, str
end,
})