From 71fb8da0890f302cd7a37b79f0d3f9672cf6a6ab Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Mon, 28 Jun 2021 20:17:43 -0700 Subject: [PATCH 01/25] refactor s-tool init --- .../commands/selectors/init.lua | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/worldeditadditions_commands/commands/selectors/init.lua b/worldeditadditions_commands/commands/selectors/init.lua index 84a05cb..8e9ac32 100644 --- a/worldeditadditions_commands/commands/selectors/init.lua +++ b/worldeditadditions_commands/commands/selectors/init.lua @@ -6,17 +6,16 @@ -- Chat commands that operate on selections. -local we_c = worldeditadditions_commands -we_c.modpath = minetest.get_modpath("worldeditadditions_commands") +local we_cm = worldeditadditions_commands.modpath .. "/commands/selectors/" -dofile(we_c.modpath.."/commands/selectors/srel.lua") -dofile(we_c.modpath.."/commands/selectors/scentre.lua") -dofile(we_c.modpath.."/commands/selectors/scloud.lua") -dofile(we_c.modpath.."/commands/selectors/scol.lua") -dofile(we_c.modpath.."/commands/selectors/scube.lua") -dofile(we_c.modpath.."/commands/selectors/sfactor.lua") -dofile(we_c.modpath.."/commands/selectors/smake.lua") -dofile(we_c.modpath.."/commands/selectors/spop.lua") -dofile(we_c.modpath.."/commands/selectors/spush.lua") -dofile(we_c.modpath.."/commands/selectors/srect.lua") -dofile(we_c.modpath.."/commands/selectors/sstack.lua") +dofile(we_cm.."srel.lua") +dofile(we_cm.."scentre.lua") +dofile(we_cm.."scloud.lua") +dofile(we_cm.."scol.lua") +dofile(we_cm.."scube.lua") +dofile(we_cm.."sfactor.lua") +dofile(we_cm.."smake.lua") +dofile(we_cm.."spop.lua") +dofile(we_cm.."spush.lua") +dofile(we_cm.."srect.lua") +dofile(we_cm.."sstack.lua") From d65fe98de6b5da0fb3adf0221e65c57ca4251393 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Mon, 28 Jun 2021 21:15:47 -0700 Subject: [PATCH 02/25] added mface --- .../commands/measure/init.lua | 11 ++++++ .../commands/measure/mface.lua | 37 +++++++++++++++++++ worldeditadditions_commands/init.lua | 10 ++++- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 worldeditadditions_commands/commands/measure/init.lua create mode 100644 worldeditadditions_commands/commands/measure/mface.lua diff --git a/worldeditadditions_commands/commands/measure/init.lua b/worldeditadditions_commands/commands/measure/init.lua new file mode 100644 index 0000000..e8ce9c9 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/init.lua @@ -0,0 +1,11 @@ +-- ███ ███ ███████ █████ ███████ ██ ██ ██████ ███████ +-- ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ████ ██ █████ ███████ ███████ ██ ██ ██████ █████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ███████ ██ ██ ███████ ██████ ██ ██ ███████ + +-- Chat commands that measure things. + +local we_cm = worldeditadditions_commands.modpath .. "/commands/measure/" + +dofile(we_cm.."mface.lua") diff --git a/worldeditadditions_commands/commands/measure/mface.lua b/worldeditadditions_commands/commands/measure/mface.lua new file mode 100644 index 0000000..53249e6 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/mface.lua @@ -0,0 +1,37 @@ +-- ███ ███ ███████ █████ ██████ ███████ +-- ████ ████ ██ ██ ██ ██ ██ +-- ██ ████ ██ █████ ███████ ██ █████ +-- ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ ██████ ███████ +local wea = worldeditadditions +worldedit.register_command("mface", { + params = "", + description = "Return player facing axis.", + privs = { worldedit = true }, + require_pos = 0, + parse = function(params_text) + return true + end, + func = function(name, params_text) + local str = "You are facing " + local dir = minetest.get_player_by_name(name):get_look_dir() + + if math.abs(dir.z) > math.abs(dir.x) then + if dir.z < 0 then str = str.."-Z" + else str = str.."Z" end + if math.abs(dir.x) >= 0.35 then -- Alternate value: 1/3 + if dir.x < 0 then str = str.."-X" + else str = str.."X" end + end + else + if dir.x < 0 then str = str.."-X" + else str = str.."X" end + if math.abs(dir.z) >= 0.35 then -- Alternate value: 1/3 + if dir.z < 0 then str = str.."-Z" + else str = str.."Z" end + end + end + + return true, str + end, +}) diff --git a/worldeditadditions_commands/init.lua b/worldeditadditions_commands/init.lua index f435b8c..d99c26e 100644 --- a/worldeditadditions_commands/init.lua +++ b/worldeditadditions_commands/init.lua @@ -44,6 +44,9 @@ dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua") -- Selection Tools dofile(we_c.modpath.."/commands/selectors/init.lua") +-- Measure Tools +dofile(we_c.modpath.."/commands/measure/init.lua") + dofile(we_c.modpath.."/commands/extra/saplingaliases.lua") dofile(we_c.modpath.."/commands/extra/basename.lua") @@ -76,6 +79,9 @@ worldedit.alias_command("naturalize", "layers") worldedit.alias_command("flora", "bonemeal") -worldedit.alias_command("mcount", "count") - +-- Selection Tools worldedit.alias_command("sfac", "sfactor") + +-- Measure Tools +worldedit.alias_command("mcount", "count") +worldedit.alias_command("mfacing", "mface") From ba93cb7bea9b00f75a93e9b39e5418a88c37d9d6 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 29 Jun 2021 18:53:14 -0700 Subject: [PATCH 03/25] added WEA Core --- worldeditadditions_core/init.lua | 18 ++++++++++++++++++ worldeditadditions_core/register/check.lua | 14 ++++++++++++++ worldeditadditions_core/register/init.lua | 15 +++++++++++++++ worldeditadditions_core/register/override.lua | 18 ++++++++++++++++++ worldeditadditions_core/register/register.lua | 18 ++++++++++++++++++ worldeditadditions_core/worldedit/init.lua | 5 +++++ 6 files changed, 88 insertions(+) create mode 100644 worldeditadditions_core/init.lua create mode 100644 worldeditadditions_core/register/check.lua create mode 100644 worldeditadditions_core/register/init.lua create mode 100644 worldeditadditions_core/register/override.lua create mode 100644 worldeditadditions_core/register/register.lua create mode 100644 worldeditadditions_core/worldedit/init.lua diff --git a/worldeditadditions_core/init.lua b/worldeditadditions_core/init.lua new file mode 100644 index 0000000..f4f2531 --- /dev/null +++ b/worldeditadditions_core/init.lua @@ -0,0 +1,18 @@ +--- WorldEditAdditions-Core +-- @module worldeditadditions_core +-- @release 1.13 +-- @copyright 2021 Starbeamrainbowlabs and VorTechnix +-- @license Mozilla Public License, 2.0 +-- @author Starbeamrainbowlabs and VorTechnix + +worldeditadditions_core = {} +local we_c = worldeditadditions_core + +we_c.modpath = minetest.get_modpath("worldeditadditions_core") + +-- Initialze WorldEdit stuff if the WorldEdit mod is not present +if not minetest.get_modpath("worldedit") then + dofile(we_c.modpath.."/worldedit/init.lua") +end + +dofile(we_c.modpath.."/register/init.lua") diff --git a/worldeditadditions_core/register/check.lua b/worldeditadditions_core/register/check.lua new file mode 100644 index 0000000..a08a40d --- /dev/null +++ b/worldeditadditions_core/register/check.lua @@ -0,0 +1,14 @@ +function worldeditadditions.register_command(def) + local def = table.copy(def) + assert(name and #name > 0) + assert(def.privs) + def.require_pos = def.require_pos or 0 + assert(def.require_pos >= 0 and def.require_pos < 3) + if def.params == "" and not def.parse then + def.parse = function(param) return true end + else + assert(def.parse) + end + assert(def.nodes_needed == nil or type(def.nodes_needed) == "function") + assert(def.func) +end diff --git a/worldeditadditions_core/register/init.lua b/worldeditadditions_core/register/init.lua new file mode 100644 index 0000000..ddf3499 --- /dev/null +++ b/worldeditadditions_core/register/init.lua @@ -0,0 +1,15 @@ +-- ██████ ███████ ██████ ██ ███████ ████████ ███████ ██████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██████ █████ ██ ███ ██ ███████ ██ █████ ██████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██ + +-- WorldEditAdditions Register/Overwrite Functions + +--TODO: Replicate chatcommand_handler functionality (worldedit_commands/init.lua line 21-60) + +local we_cm = worldeditadditions_core.modpath .. "/register/" + +dofile(we_cm.."check.lua") +dofile(we_cm.."register.lua") +dofile(we_cm.."override.lua") diff --git a/worldeditadditions_core/register/override.lua b/worldeditadditions_core/register/override.lua new file mode 100644 index 0000000..e0d63db --- /dev/null +++ b/worldeditadditions_core/register/override.lua @@ -0,0 +1,18 @@ +local we_c = worldeditadditions_core +function we_c.override_command(name, def) + local success, def = we_c.check(def) + + if not success then + return false, def + end + + minetest.override_chatcommand("/" .. name, { + privs = def.privs, + params = def.params, + description = def.description, + func = function(player_name, param) + return chatcommand_handler(name, player_name, param) + end, + }) + worldedit.registered_commands[name] = def +end diff --git a/worldeditadditions_core/register/register.lua b/worldeditadditions_core/register/register.lua new file mode 100644 index 0000000..ebf8dfc --- /dev/null +++ b/worldeditadditions_core/register/register.lua @@ -0,0 +1,18 @@ +local we_c = worldeditadditions_core +function we_c.register_command(name, def) + local success, def = we_c.check(def) + + if not success then + return false, def + end + + minetest.register_chatcommand("/" .. name, { + privs = def.privs, + params = def.params, + description = def.description, + func = function(player_name, param) + return chatcommand_handler(name, player_name, param) + end, + }) + worldedit.registered_commands[name] = def +end diff --git a/worldeditadditions_core/worldedit/init.lua b/worldeditadditions_core/worldedit/init.lua new file mode 100644 index 0000000..fc4fd8b --- /dev/null +++ b/worldeditadditions_core/worldedit/init.lua @@ -0,0 +1,5 @@ +--- WorldEdit dependencies for WorldEditAdditions + +worldedit = { + registered_commands = {} +} From 9ad27404b0e41da6ac76e19be096864772b38199 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 08:36:04 -0700 Subject: [PATCH 04/25] implemented chatcommand_handler --- worldeditadditions_core/register/check.lua | 2 +- worldeditadditions_core/register/handler.lua | 40 +++++++++++++++++++ worldeditadditions_core/register/init.lua | 1 + worldeditadditions_core/register/override.lua | 2 +- worldeditadditions_core/register/register.lua | 2 +- 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 worldeditadditions_core/register/handler.lua diff --git a/worldeditadditions_core/register/check.lua b/worldeditadditions_core/register/check.lua index a08a40d..6274a74 100644 --- a/worldeditadditions_core/register/check.lua +++ b/worldeditadditions_core/register/check.lua @@ -1,4 +1,4 @@ -function worldeditadditions.register_command(def) +function worldeditadditions_core.register_command(def) local def = table.copy(def) assert(name and #name > 0) assert(def.privs) diff --git a/worldeditadditions_core/register/handler.lua b/worldeditadditions_core/register/handler.lua new file mode 100644 index 0000000..b80c4a6 --- /dev/null +++ b/worldeditadditions_core/register/handler.lua @@ -0,0 +1,40 @@ +function worldeditadditions_core.chatcommand_handler(cmd_name, name, param) + local def = assert(worldedit.registered_commands[cmd_name]) + + if def.require_pos == 2 then + local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] + if pos1 == nil or pos2 == nil then + worldedit.player_notify(name, "no region selected") + return + end + elseif def.require_pos == 1 then + local pos1 = worldedit.pos1[name] + if pos1 == nil then + worldedit.player_notify(name, "no position 1 selected") + return + end + end + + local parsed = {def.parse(param)} + local success = table.remove(parsed, 1) + if not success then + worldedit.player_notify(name, parsed[1] or "invalid usage") + return + end + + if def.nodes_needed then + local count = def.nodes_needed(name, unpack(parsed)) + safe_region(name, count, function() + local success, msg = def.func(name, unpack(parsed)) + if msg then + minetest.chat_send_player(name, msg) + end + end) + else + -- no "safe region" check + local success, msg = def.func(name, unpack(parsed)) + if msg then + minetest.chat_send_player(name, msg) + end + end +end diff --git a/worldeditadditions_core/register/init.lua b/worldeditadditions_core/register/init.lua index ddf3499..50508e3 100644 --- a/worldeditadditions_core/register/init.lua +++ b/worldeditadditions_core/register/init.lua @@ -11,5 +11,6 @@ local we_cm = worldeditadditions_core.modpath .. "/register/" dofile(we_cm.."check.lua") +dofile(we_cm.."handler.lua") dofile(we_cm.."register.lua") dofile(we_cm.."override.lua") diff --git a/worldeditadditions_core/register/override.lua b/worldeditadditions_core/register/override.lua index e0d63db..bf7bb4e 100644 --- a/worldeditadditions_core/register/override.lua +++ b/worldeditadditions_core/register/override.lua @@ -11,7 +11,7 @@ function we_c.override_command(name, def) params = def.params, description = def.description, func = function(player_name, param) - return chatcommand_handler(name, player_name, param) + return we_c.chatcommand_handler(name, player_name, param) end, }) worldedit.registered_commands[name] = def diff --git a/worldeditadditions_core/register/register.lua b/worldeditadditions_core/register/register.lua index ebf8dfc..2a93120 100644 --- a/worldeditadditions_core/register/register.lua +++ b/worldeditadditions_core/register/register.lua @@ -11,7 +11,7 @@ function we_c.register_command(name, def) params = def.params, description = def.description, func = function(player_name, param) - return chatcommand_handler(name, player_name, param) + return we_c.chatcommand_handler(name, player_name, param) end, }) worldedit.registered_commands[name] = def From 11bf486bf2cdbfa69a3a5a48a26076fd54b9053e Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 11:14:31 -0700 Subject: [PATCH 05/25] Update init.lua --- worldeditadditions_core/register/init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/worldeditadditions_core/register/init.lua b/worldeditadditions_core/register/init.lua index 50508e3..2ebb6c5 100644 --- a/worldeditadditions_core/register/init.lua +++ b/worldeditadditions_core/register/init.lua @@ -6,8 +6,6 @@ -- WorldEditAdditions Register/Overwrite Functions ---TODO: Replicate chatcommand_handler functionality (worldedit_commands/init.lua line 21-60) - local we_cm = worldeditadditions_core.modpath .. "/register/" dofile(we_cm.."check.lua") 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 06/25] //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, +}) From 484b7532eb9b778fc2d7d16d1a6dc84838af87a2 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 11:59:19 -0700 Subject: [PATCH 07/25] fixed table.tostring --- worldeditadditions/utils/tables/table_tostring.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/worldeditadditions/utils/tables/table_tostring.lua b/worldeditadditions/utils/tables/table_tostring.lua index e6e8250..89f9b80 100644 --- a/worldeditadditions/utils/tables/table_tostring.lua +++ b/worldeditadditions/utils/tables/table_tostring.lua @@ -9,12 +9,12 @@ local function table_tostring(tbl, sep, new_line) local ret = {} if type(tbl) ~= "table" then return "Error: input not table!" end for key,value in pairs(tbl) do - ret:append(key) - ret:append(sep) - ret:append(value) - ret:append(new_line) + table.insert(ret,key) + table.insert(ret,sep) + table.insert(ret,value) + table.insert(ret,new_line) end - return ret:concat("") + return table.concat(ret,"") end return table_tostring From f709d12b75de63ff6856f06cb8c799a8ddb11fd6 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 22:11:34 -0700 Subject: [PATCH 08/25] Update table_tostring.lua --- .../utils/tables/table_tostring.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/worldeditadditions/utils/tables/table_tostring.lua b/worldeditadditions/utils/tables/table_tostring.lua index 89f9b80..4a13586 100644 --- a/worldeditadditions/utils/tables/table_tostring.lua +++ b/worldeditadditions/utils/tables/table_tostring.lua @@ -4,17 +4,14 @@ -- @param new_line string key value pair delimiter -- @return string concatenated table pairs local function table_tostring(tbl, sep, new_line) - if type(sep) ~= "string" then sep = ": " end - if type(new_line) ~= "string" then new_line = ", " end - local ret = {} - if type(tbl) ~= "table" then return "Error: input not table!" end - for key,value in pairs(tbl) do - table.insert(ret,key) - table.insert(ret,sep) - table.insert(ret,value) - table.insert(ret,new_line) - end - return table.concat(ret,"") + if type(sep) ~= "string" then sep = ": " end + if type(new_line) ~= "string" then new_line = ", " end + local ret = {} + if type(tbl) ~= "table" then return "Error: input not table!" end + for key,value in pairs(tbl) do + table.insert(ret,tostring(key) .. sep .. tostring(value) .. new_line) + end + return table.concat(ret,"") end return table_tostring From e047372c22ad9391ab5d86e2def0a4c4c8f949c4 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Fri, 2 Jul 2021 20:10:03 -0700 Subject: [PATCH 09/25] Added //msize --- .../commands/measure/init.lua | 1 + .../commands/measure/msize.lua | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 worldeditadditions_commands/commands/measure/msize.lua diff --git a/worldeditadditions_commands/commands/measure/init.lua b/worldeditadditions_commands/commands/measure/init.lua index dd44bef..bd0e0ca 100644 --- a/worldeditadditions_commands/commands/measure/init.lua +++ b/worldeditadditions_commands/commands/measure/init.lua @@ -10,3 +10,4 @@ local we_cm = worldeditadditions_commands.modpath .. "/commands/measure/" dofile(we_cm.."mface.lua") dofile(we_cm.."midpos.lua") +dofile(we_cm.."msize.lua") diff --git a/worldeditadditions_commands/commands/measure/msize.lua b/worldeditadditions_commands/commands/measure/msize.lua new file mode 100644 index 0000000..177c330 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/msize.lua @@ -0,0 +1,22 @@ +-- ███ ███ ███████ ██ ███████ ███████ +-- ████ ████ ██ ██ ███ ██ +-- ██ ████ ██ ███████ ██ ███ █████ +-- ██ ██ ██ ██ ██ ███ ██ +-- ██ ██ ███████ ██ ███████ ███████ +local wea = worldeditadditions +worldedit.register_command("msize", { + 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 " + local vec = vector.subtract(worldedit.pos2[name],worldedit.pos1[name]) + wea.vector.abs(vec) + + return true, str .. wea.table.tostring(vec) + end, +}) 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 10/25] 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, +}) From d69dae5087644fe40f21a36b6028ac6b685a059a Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 8 Jul 2021 21:04:51 -0700 Subject: [PATCH 11/25] comment out worldedit debug stuff --- worldeditadditions_commands/commands/measure/mtrig.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index e107cf1..5fc5f46 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -4,7 +4,7 @@ -- ██ ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██ ██████ local wea = worldeditadditions -worldeditdebug.register("abschk") +-- worldeditdebug.register("abschk") worldedit.register_command("mtrig", { params = "", description = "Return the length of each axis of current selection.", @@ -18,10 +18,10 @@ worldedit.register_command("mtrig", { 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 + -- 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 From f94906c85491efc3195afdec24053ca92003ddd6 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 09:08:56 -0700 Subject: [PATCH 12/25] force output syntax in msize --- worldeditadditions_commands/commands/measure/msize.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/measure/msize.lua b/worldeditadditions_commands/commands/measure/msize.lua index 177c330..648f02f 100644 --- a/worldeditadditions_commands/commands/measure/msize.lua +++ b/worldeditadditions_commands/commands/measure/msize.lua @@ -17,6 +17,6 @@ worldedit.register_command("msize", { local vec = vector.subtract(worldedit.pos2[name],worldedit.pos1[name]) wea.vector.abs(vec) - return true, str .. wea.table.tostring(vec) + return true, str .. "x: " .. vec.x .. ", y: " .. vec.y .. ", z: " .. vec.z end, }) From 3f6b8f4d21e32e695cee8838b9fc9fac113f1ca9 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 09:09:40 -0700 Subject: [PATCH 13/25] Fix and stabilize //mtrig --- .../commands/measure/mtrig.lua | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index 5fc5f46..d955f79 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -1,10 +1,10 @@ --- ███ ███ ██████ ████████ ██ ██████ --- ████ ████ ██ ██ ██ ██ ██ --- ██ ████ ██ ██████ ██ ██ ██ ███ --- ██ ██ ██ ██ ██ ██ ██ ██ ██ --- ██ ██ ██ ██ ██ ██ ██████ +-- ███ ███ ████████ ██████ ██ ██████ +-- ████ ████ ██ ██ ██ ██ ██ +-- ██ ████ ██ ██ ██████ ██ ██ ███ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ ██ ██████ local wea = worldeditadditions --- worldeditdebug.register("abschk") +local v3 = worldeditadditions.Vector3 worldedit.register_command("mtrig", { params = "", description = "Return the length of each axis of current selection.", @@ -14,16 +14,10 @@ worldedit.register_command("mtrig", { 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).."°" + local str = "The measurements of the line pos1,pos2 are Length (D): " + local vec = v3.subtract(worldedit.pos2[name],worldedit.pos1[name]):abs() + local len = vec:length() + str = str..len..", ∠XZ: "..math.deg(math.atan(vec.z/vec.x)).."° ∠DY: "..math.deg(math.asin(vec.y/len)).."°" return true, str end, }) From 9d2a0ca23c8bcf9199962a0e785cd4bed063f25d Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 09:54:11 -0700 Subject: [PATCH 14/25] round mtrig values --- worldeditadditions_commands/commands/measure/mtrig.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index d955f79..962abeb 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -17,7 +17,7 @@ worldedit.register_command("mtrig", { local str = "The measurements of the line pos1,pos2 are Length (D): " local vec = v3.subtract(worldedit.pos2[name],worldedit.pos1[name]):abs() local len = vec:length() - str = str..len..", ∠XZ: "..math.deg(math.atan(vec.z/vec.x)).."° ∠DY: "..math.deg(math.asin(vec.y/len)).."°" + 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).."°" return true, str end, }) From 428ec12918a8eb199d7b2c5f716890ba7501ccc4 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 09:59:53 -0700 Subject: [PATCH 15/25] Update mtrig.lua --- worldeditadditions_commands/commands/measure/mtrig.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index 962abeb..3e524b0 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -17,7 +17,9 @@ worldedit.register_command("mtrig", { local str = "The measurements of the line pos1,pos2 are Length (D): " local vec = v3.subtract(worldedit.pos2[name],worldedit.pos1[name]):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.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).."°" return true, str end, }) From 5ac0b8a04cde50209bbfaed391d94c4851790e51 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:43:56 -0700 Subject: [PATCH 16/25] Update mtrig.lua --- worldeditadditions_commands/commands/measure/mtrig.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index 3e524b0..dc0be7c 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -7,7 +7,7 @@ local wea = worldeditadditions local v3 = worldeditadditions.Vector3 worldedit.register_command("mtrig", { params = "", - description = "Return the length of each axis of current selection.", + description = "Return the length of and angles of an imginary line between pos1 and pos2 in the selection.", privs = { worldedit = true }, require_pos = 2, parse = function(params_text) From 0d7043b537cda85ce7a4da111ba2bad3aa56ac7a Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:44:18 -0700 Subject: [PATCH 17/25] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index caecfe9..72787a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Note to self: See the bottom of this file for the release template text. ## v1.13: Untitled update (unreleased) - Add `//sfactor` (_selection factor_) - Selection Tools by @VorTechnix are finished for now. + - Add `mface` (_measure facing_), `midpos` (_measure middle position_), `msize` (_measure size_), `mtrig` (_measure trigonometry_) - Measuring Tools implemented by @VorTechnix. ## v1.12: The selection tools update (26th June 2021) - Add `//spush`, `//spop`, and `//sstack` From b605ab5a5c386c46558d52df7d5901a94989f8d4 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 11:31:22 -0700 Subject: [PATCH 18/25] added m-tools to chat com ref --- Chat-Command-Reference.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 3414858..c68b360 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -712,6 +712,34 @@ Pops a selection off your per-user selection stack and applies it to the current //spop ``` +## `//mface` +Returns the horizontal (X/Z) axis or axes the player is looking along. + +``` +//mface +``` + +## `//midpos` +Returns the coordinates of the centre of the current selection. + +``` +//midpos +``` + +## `//msize` +Returns the lengths of the current selection on the X, Y and Z axes. + +``` +//msize +``` + +## `//mtrig` +Returns the length of the diagonal pos1,pos2 and it's angle on the XZ and h/Y axes. + +``` +//mtrig +``` + ## `//y` Confirms the execution of a command if it could potentially affect a large number of nodes and take a while. This is a regular WorldEdit command. From a6d5ead0420c84b0dcdff178d78869867d3eac35 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 11:45:06 -0700 Subject: [PATCH 19/25] m-tools docs update --- Chat-Command-Reference.md | 7 +++++++ README.md | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index c68b360..40032c3 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -712,6 +712,13 @@ Pops a selection off your per-user selection stack and applies it to the current //spop ``` +## `//mcount` +Alias for [`//count`](#count). + +``` +//mface +``` + ## `//mface` Returns the horizontal (X/Z) axis or axes the player is looking along. diff --git a/README.md b/README.md index 0db3fd5..58a7adc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,13 @@ The detailed explanations have moved! Check them out [here](https://github.com/s - [`//sstack`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#sstack) - [`//spush`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#spush) - [`//spop`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#spop) - + +### Measure + - [`//mface`](Chat-Command-Reference.md#mface) + - [`//midpos`](Chat-Command-Reference.md#midpos) + - [`//msize`](Chat-Command-Reference.md#msize) + - [`//mtrig`](Chat-Command-Reference.md#mtrig) + ### Meta - [`//multi ....`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#multi-command_a-command_b-command_c-) - [`//many `](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#many-times-command) _(new in v1.9)_ From e3dd7ae4283b832b6ebbbf7d3f930e8a00fab2c1 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 12:00:05 -0700 Subject: [PATCH 20/25] fixed optional dependency on worleditdebug --- worldeditadditions_commands/depends.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/depends.txt b/worldeditadditions_commands/depends.txt index db6f73b..3f0059a 100644 --- a/worldeditadditions_commands/depends.txt +++ b/worldeditadditions_commands/depends.txt @@ -2,5 +2,5 @@ worldeditadditions worldedit_commands worldedit_shortcommands worldedit -worldeditadditions_debug? +worldeditdebug? bonemeal? From a06413977e0d17344ee90055750ccc53434dbc1f Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 13:29:25 -0700 Subject: [PATCH 21/25] fix mcount Chat-Command-Reference.md Co-authored-by: Starbeamrainbowlabs --- Chat-Command-Reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 2007601..87f05d3 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -784,7 +784,7 @@ Pops a selection off your per-user selection stack and applies it to the current Alias for [`//count`](#count). ``` -//mface +//mcount ``` ## `//mface` From 0ad0c63defb78e0552b2d1c2f320fe3c2f07d141 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 13:44:56 -0700 Subject: [PATCH 22/25] Fix typos in mtools Co-authored-by: Starbeamrainbowlabs --- Chat-Command-Reference.md | 3 ++- worldeditadditions_commands/commands/measure/mtrig.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 87f05d3..a2410eb 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -789,6 +789,7 @@ Alias for [`//count`](#count). ## `//mface` Returns the horizontal (X/Z) axis or axes the player is looking along. +Aliases: `//mfacing`. ``` //mface @@ -809,7 +810,7 @@ Returns the lengths of the current selection on the X, Y and Z axes. ``` ## `//mtrig` -Returns the length of the diagonal pos1,pos2 and it's angle on the XZ and h/Y axes. +Returns the length of the diagonal from pos1 to pos2 and its angle on the XZ (horizontal) and Y (vertical) axes. ``` //mtrig diff --git a/worldeditadditions_commands/commands/measure/mtrig.lua b/worldeditadditions_commands/commands/measure/mtrig.lua index dc0be7c..90a28c4 100644 --- a/worldeditadditions_commands/commands/measure/mtrig.lua +++ b/worldeditadditions_commands/commands/measure/mtrig.lua @@ -14,7 +14,7 @@ worldedit.register_command("mtrig", { return true end, func = function(name, params_text) - local str = "The measurements of the line pos1,pos2 are Length (D): " + 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 len = vec:length() str = str..wea.round(len, 4)..", ∠XZ: ".. From 7b651d7abec58b9bd2d2dfafd52b6e4fa392a376 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 13:47:37 -0700 Subject: [PATCH 23/25] Fix typo worldeditadditions_core/init.lua Co-authored-by: Starbeamrainbowlabs --- worldeditadditions_core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_core/init.lua b/worldeditadditions_core/init.lua index f4f2531..e4e22ad 100644 --- a/worldeditadditions_core/init.lua +++ b/worldeditadditions_core/init.lua @@ -10,7 +10,7 @@ local we_c = worldeditadditions_core we_c.modpath = minetest.get_modpath("worldeditadditions_core") --- Initialze WorldEdit stuff if the WorldEdit mod is not present +-- Initialise WorldEdit stuff if the WorldEdit mod is not present if not minetest.get_modpath("worldedit") then dofile(we_c.modpath.."/worldedit/init.lua") end From 49617b7f47858d7abbf3048b5cceb241bd1663bf Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 14:04:43 -0700 Subject: [PATCH 24/25] params_text in def.parse worldeditadditions_core/register/check.lua Co-authored-by: Starbeamrainbowlabs --- worldeditadditions_core/register/check.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_core/register/check.lua b/worldeditadditions_core/register/check.lua index 6274a74..1dfb87b 100644 --- a/worldeditadditions_core/register/check.lua +++ b/worldeditadditions_core/register/check.lua @@ -5,7 +5,7 @@ function worldeditadditions_core.register_command(def) def.require_pos = def.require_pos or 0 assert(def.require_pos >= 0 and def.require_pos < 3) if def.params == "" and not def.parse then - def.parse = function(param) return true end + def.parse = function(params_text) return true end else assert(def.parse) end From caed5e7195eea71549957cecb5d0c081944e5cda Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 15 Jul 2021 14:09:14 -0700 Subject: [PATCH 25/25] Create depends.txt --- worldeditadditions_core/depends.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 worldeditadditions_core/depends.txt diff --git a/worldeditadditions_core/depends.txt b/worldeditadditions_core/depends.txt new file mode 100644 index 0000000..c4f6871 --- /dev/null +++ b/worldeditadditions_core/depends.txt @@ -0,0 +1 @@ +worldedit?