From d479e167b987944e91c804e0673312a68c143feb Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 11:14:45 -0700 Subject: [PATCH] //midpos implemented --- .../commands/measure/init.lua | 1 + .../commands/measure/midpos.lua | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 worldeditadditions_commands/commands/measure/midpos.lua diff --git a/worldeditadditions_commands/commands/measure/init.lua b/worldeditadditions_commands/commands/measure/init.lua index e8ce9c9..dd44bef 100644 --- a/worldeditadditions_commands/commands/measure/init.lua +++ b/worldeditadditions_commands/commands/measure/init.lua @@ -9,3 +9,4 @@ local we_cm = worldeditadditions_commands.modpath .. "/commands/measure/" dofile(we_cm.."mface.lua") +dofile(we_cm.."midpos.lua") diff --git a/worldeditadditions_commands/commands/measure/midpos.lua b/worldeditadditions_commands/commands/measure/midpos.lua new file mode 100644 index 0000000..a2fee5f --- /dev/null +++ b/worldeditadditions_commands/commands/measure/midpos.lua @@ -0,0 +1,21 @@ +-- ███ ███ ██ ██████ ██████ ██████ ███████ +-- ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ████ ██ ██ ██ ██ ██████ ██ ██ ███████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██████ ██ ██████ ███████ +local wea = worldeditadditions +worldedit.register_command("midpos", { + params = "", + description = "Return the mid point of current selection.", + privs = { worldedit = true }, + require_pos = 2, + parse = function(params_text) + return true + 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) + end, +})