From 71460cb31656ebf3ee3c33fba3afd1c60500558d Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 8 Jul 2021 20:54:05 -0700 Subject: [PATCH] Added mtrig (vector3 broken) --- .../commands/measure/init.lua | 1 + .../commands/measure/mtrig.lua | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 worldeditadditions_commands/commands/measure/mtrig.lua diff --git a/worldeditadditions_commands/commands/measure/init.lua b/worldeditadditions_commands/commands/measure/init.lua index bd0e0ca..126e1ec 100644 --- a/worldeditadditions_commands/commands/measure/init.lua +++ b/worldeditadditions_commands/commands/measure/init.lua @@ -11,3 +11,4 @@ local we_cm = 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") diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua new file mode 100644 index 0000000..e107cf1 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -0,0 +1,29 @@ +-- ███ ███ ██████ ████████ ██ ██████ +-- ████ ████ ██ ██ ██ ██ ██ +-- ██ ████ ██ ██████ ██ ██ ██ ███ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ ██ ██████ +local wea = worldeditadditions +worldeditdebug.register("abschk") +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: + if worldeditdebug.debug["abschk"][name] then + -- //debug abschk + return false, "Values = " .. worldeditdebug.table_tostring(vec) + end + 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, +})