From a671f742e9b38e47f57b38fe7c7d32f5bb9e685e Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 9 Mar 2021 11:05:03 -0800 Subject: [PATCH 1/6] scol and srect refactor --- worldeditadditions/utils/numbers.lua | 21 +++------ worldeditadditions/utils/selector_helps.lua | 18 +++++-- .../commands/selectors/scol.lua | 47 +++++++++++++++++++ .../commands/selectors/srect.lua | 46 +++++++----------- worldeditadditions_commands/init.lua | 2 +- 5 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 worldeditadditions_commands/commands/selectors/scol.lua diff --git a/worldeditadditions/utils/numbers.lua b/worldeditadditions/utils/numbers.lua index f287199..84d34f2 100644 --- a/worldeditadditions/utils/numbers.lua +++ b/worldeditadditions/utils/numbers.lua @@ -42,21 +42,12 @@ function worldeditadditions.eta(existing_times, done_count, total_count) end --- Returns the sign (+ or -) at the beginning of a string if present. --- @param str string Input string. --- @param type string The type of value to return. Valid values: "string" (default), "int" --- @return string|int Returns the sign string or signed multiplier (1|-1). -function worldeditadditions.getsign(str, type) - if not type then type = "string" end - if not (type == "string" or type == "int") then - return false, "Error: Unknown type '"..type.."'." - end - if str:sub(1, 1) == "-" then - if type == "int" then return true, -1 - else return true, "-" end - else - if type == "int" then return true, 1 - else return true, "+" end - end +-- @param src string|int Input string. +-- @return string|int Returns the signed multiplier (1|-1). +function worldeditadditions.getsign(src) + if type(src) == "number" then return src < 0 and -1 or 1 + elseif type(src) ~= "string" then return 1 + else return src:match('-') and -1 or 1 end end -- For Testing: diff --git a/worldeditadditions/utils/selector_helps.lua b/worldeditadditions/utils/selector_helps.lua index 60d31ba..28e96fc 100644 --- a/worldeditadditions/utils/selector_helps.lua +++ b/worldeditadditions/utils/selector_helps.lua @@ -1,11 +1,21 @@ -- Returns the player's facing direction on the horizontal axes only. -- @param name string The name of the player to return facing direction of. --- @return table Returns axis name and sign multiplyer. +-- @return Returns axis name and sign multiplier. function worldeditadditions.player_axis2d(name) -- minetest.get_player_by_name("singleplayer"): - local dir = math.floor(minetest.get_player_by_name(name):get_look_horizontal() / math.pi * 2 + 0.5) % 4 - local crdnl = { {1,"z"},{-1,"x"},{-1,"z"},{1,"x"} } - return crdnl[dir+1] + local dir = minetest.get_player_by_name(name):get_look_dir() + local x, z= math.abs(dir.x), math.abs(dir.z) + if x > z then return "x", dir.x > 0 and 1 or -1 + else return "z", dir.z > 0 and 1 or -1 end +end +-- Returns the axis and sign of the axis to the left of the input axis. +-- @param axis string x or z. +-- @param sign int Sign multiplier. +-- @return Returns axis name and sign multiplier. +function worldeditadditions.axis_left(axis,sign) + if not axis:match("[xz]") then return false, "Error: Not a horizontal axis!" + elseif axis == "x" then return true, "z", sign + else return true, "x", -sign end end -- Tests diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua new file mode 100644 index 0000000..c03ba69 --- /dev/null +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -0,0 +1,47 @@ +-- ███████ ██████ ██████ ██ +-- ██ ██ ██ ██ ██ +-- ███████ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ +-- ███████ ██████ ██████ ███████ +worldedit.register_command("scol", { + params = "[] ", + description = "Set WorldEdit region position 2 at a set distance along 1 axis.", + privs = {worldedit=true}, + require_pos = 1, + parse = function(params_text) + local wea = worldeditadditions + local find = wea.split(params_text, "%s", false) + local ax1, len = find[1], find[table.maxn(find)] + + -- If ax1 is bad set to player facing dir + if ax1 == len or not ax1:match('[xyz]') then ax1 = "get" + else ax1 = { wea.getsign(ax1), ax1:gsub('[^xyz]', ''):sub(1, 1) } end + + len = tonumber(len) + -- If len == nill cancel the operation + if len == nil then + return false, "No length specified." + end + + return true, ax1, len + end, + func = function(name, axis1, len) + if axis1 == "get" then + ax1, dir = worldedit.player_axis(name) + axis1 = {dir,ax1} + end + + local p2 = vector.new(worldedit.pos1[name]) + p2[axis1[2]] = p2[axis1[2]] + tonumber(len) * axis1[1] + + worldedit.pos2[name] = p2 + worldedit.mark_pos2(name) + return true, "position 2 set to " .. minetest.pos_to_string(p2) + end, +}) + +-- Tests +-- /multi //fp set1 -63 19 -20 //scol 5 + +-- lua print(worldedit.player_axis(myname)) +-- tonumber(('y1'):gsub('[xyz]',''):sub(1,2)) diff --git a/worldeditadditions_commands/commands/selectors/srect.lua b/worldeditadditions_commands/commands/selectors/srect.lua index 1ddc602..e477d40 100644 --- a/worldeditadditions_commands/commands/selectors/srect.lua +++ b/worldeditadditions_commands/commands/selectors/srect.lua @@ -9,39 +9,28 @@ worldedit.register_command("srect", { privs = { worldedit = true }, require_pos = 1, parse = function(params_text) - local wea = worldeditadditions + local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) - local ax1, ax2, len = find[1], find[2], find[table.maxn(find)] + local ax1, ax2 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "y"):sub(1,1) + local sn1, sn2, len = wea.getsign(find[1]), wea.getsign(find[2]), find[table.maxn(find)] - -- If ax1 is bad set to player facing dir - if ax1 == len or not ax1:match('[xyz]') then ax1 = "get" - else - local success, value = wea.getsign(ax1, "int") - if not success then return success, value - else ax1 = { value, ax1:gsub('[^xyz]', ''):sub(1, 1) } end - end - -- If ax2 is bad set to +y - if not ax2 or ax2 == len or not ax2:match('[xyz]') then ax2 = "y" end - local success, value = wea.getsign(ax2, "int") - if not success then return success, value end - ax2 = { value, ax2:gsub('[^xyz]', ''):sub(1, 1) } - - len = tonumber(len) + tmp.len = tonumber(len) -- If len == nill cancel the operation - if len == nil then - return false, "No length specified." + if tmp.len == nil then return false, "No length specified." end + -- If ax1 is bad send "get" order + if ax1 == "g" then tmp.get = true + else vec[ax1] = sn1 * tmp.len end + vec[ax2] = sn2 * tmp.len + + return true, vec, tmp + end, + func = function(name, vec, tmp) + if tmp.get then + local ax, dir = worldeditadditions.player_axis2d(name) + vec[ax] = tmp.len * dir end - return true, ax1, ax2, len - end, - func = function(name, axis1, axis2, len) - if axis1 == "get" then axis1 = worldeditadditions.player_axis2d(name) end - - local p2 = vector.new(worldedit.pos1[name]) - - p2[axis1[2]] = p2[axis1[2]] + tonumber(len) * axis1[1] - p2[axis2[2]] = p2[axis2[2]] + tonumber(len) * axis2[1] - + p2 = vector.add(vec,worldedit.pos1[name]) worldedit.pos2[name] = p2 worldedit.mark_pos2(name) return true, "position 2 set to " .. minetest.pos_to_string(p2) @@ -56,3 +45,4 @@ worldedit.register_command("srect", { -- /multi //fp set1 -63 19 -20 //srect -z 5 -- /multi //fp set1 -63 19 -20 //srect a -x 5 -- /multi //fp set1 -63 19 -20 //srect -x -a 5 +-- lua vec = vector.new(15,-12,17); vec["len"] = 5; vec.get = true; vec2 = vector.add(vector.new(1,1,1),vec) print(vec2.x,vec2.y,vec2.z,vec2.len) diff --git a/worldeditadditions_commands/init.lua b/worldeditadditions_commands/init.lua index 75b85cf..ff1b526 100644 --- a/worldeditadditions_commands/init.lua +++ b/worldeditadditions_commands/init.lua @@ -41,7 +41,7 @@ dofile(we_c.modpath.."/commands/meta/many.lua") dofile(we_c.modpath.."/commands/meta/subdivide.lua") dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua") --- dofile(we_c.modpath.."/commands/selectors/scol.lua") +dofile(we_c.modpath.."/commands/selectors/scol.lua") dofile(we_c.modpath.."/commands/selectors/srect.lua") -- dofile(we_c.modpath.."/commands/selectors/scube.lua") dofile(we_c.modpath.."/commands/selectors/sstack.lua") From 234e0a1325b153b6844cb0c17441bdef91c98112 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Tue, 9 Mar 2021 11:19:47 -0800 Subject: [PATCH 2/6] simplified scol --- .../commands/selectors/scol.lua | 31 ++++++++----------- .../commands/selectors/srect.lua | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua index c03ba69..4ffe756 100644 --- a/worldeditadditions_commands/commands/selectors/scol.lua +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -9,31 +9,26 @@ worldedit.register_command("scol", { privs = {worldedit=true}, require_pos = 1, parse = function(params_text) - local wea = worldeditadditions + local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) - local ax1, len = find[1], find[table.maxn(find)] + local ax1, sn1, len = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), wea.getsign(find[1]), find[table.maxn(find)] - -- If ax1 is bad set to player facing dir - if ax1 == len or not ax1:match('[xyz]') then ax1 = "get" - else ax1 = { wea.getsign(ax1), ax1:gsub('[^xyz]', ''):sub(1, 1) } end - - len = tonumber(len) + tmp.len = tonumber(len) -- If len == nill cancel the operation - if len == nil then - return false, "No length specified." - end + if tmp.len == nil then return false, "No length specified." end + -- If ax1 is bad send "get" order + if ax1 == "g" then tmp.get = true + else vec[ax1] = sn1 * tmp.len end - return true, ax1, len + return true, vec, tmp end, - func = function(name, axis1, len) - if axis1 == "get" then - ax1, dir = worldedit.player_axis(name) - axis1 = {dir,ax1} + func = function(name, vec, tmp) + if tmp.get then + local ax, dir = worldeditadditions.player_axis2d(name) + vec[ax] = tmp.len * dir end - local p2 = vector.new(worldedit.pos1[name]) - p2[axis1[2]] = p2[axis1[2]] + tonumber(len) * axis1[1] - + local p2 = vector.add(vec,worldedit.pos1[name]) worldedit.pos2[name] = p2 worldedit.mark_pos2(name) return true, "position 2 set to " .. minetest.pos_to_string(p2) diff --git a/worldeditadditions_commands/commands/selectors/srect.lua b/worldeditadditions_commands/commands/selectors/srect.lua index e477d40..68af588 100644 --- a/worldeditadditions_commands/commands/selectors/srect.lua +++ b/worldeditadditions_commands/commands/selectors/srect.lua @@ -30,7 +30,7 @@ worldedit.register_command("srect", { vec[ax] = tmp.len * dir end - p2 = vector.add(vec,worldedit.pos1[name]) + local p2 = vector.add(vec,worldedit.pos1[name]) worldedit.pos2[name] = p2 worldedit.mark_pos2(name) return true, "position 2 set to " .. minetest.pos_to_string(p2) From cbd07aee4f468040ff6d14cf4bc00306652435ae Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 10 Mar 2021 13:21:33 -0800 Subject: [PATCH 3/6] scube and vector population --- CHANGELOG.md | 2 +- Chat-Command-Reference.md | 18 ++++++ .../commands/selectors/scol.lua | 2 +- .../commands/selectors/scube.lua | 55 +++++++++++++++++++ .../commands/selectors/srect.lua | 13 +++-- worldeditadditions_commands/init.lua | 2 +- 6 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 worldeditadditions_commands/commands/selectors/scube.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e0999..dafd583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ It's about time I started a changelog! This will serve from now on as the main c Note to self: See the bottom of this file for the release template text. ## v1.12 (unreleased) - - Add `//srect` (_select rectangle_) - thanks, @VorTechnix! + - Add `//srect` (_select rectangle_), `//scol` (_select column_), `//scube` (_select cube_) - thanks, @VorTechnix! - Add `//spush`, `//spop`, and `//sstack` - `//overlay`: Don't place nodes above water diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 28d765e..ede42c5 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -482,6 +482,14 @@ Executes the given command, and then clips the result to the largest ellipsoid t //ellipsoidapply layers desert_sand sand 2 desert_sandstone 4 sandstone 10 ``` +## `//scol [ ] ` +Short for _select column_. Sets the pos2 at a set distance along 1 axis from pos1. If the axis isn't specified, defaults the direction you are facing. Implementation thanks to @VorTechnix. + +``` +//scol 10 +//scol x 3 +``` + ## `//srect [ []] ` Short for _select rectangle_. Sets the pos2 at a set distance along 2 axes from pos1. If the axes aren't specified, defaults to positive y and the direction you are facing. Implementation thanks to @VorTechnix. @@ -491,6 +499,16 @@ Short for _select rectangle_. Sets the pos2 at a set distance along 2 axes from //srect -z y 25 ``` +## `//scube [ [ []]] ` +Short for _select cube_. Sets the pos2 at a set distance along 3 axes from pos1. If the axes aren't specified, defaults to positive y, the direction you are facing and the axis to the left of facing. Implementation thanks to @VorTechnix. + +``` +//scube 5 +//scube z a y 12 +//scube x z 3 +//scube -z 12 +``` + ## `//sstack` Displays the contents of your per-user selection stack. This stack can be pushed to and popped from rather like a stack of plates. See also `//spush` (for pushing to the selection stack) and `//spop` (for popping from the selection stack). diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua index 4ffe756..3e41dca 100644 --- a/worldeditadditions_commands/commands/selectors/scol.lua +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -15,7 +15,7 @@ worldedit.register_command("scol", { tmp.len = tonumber(len) -- If len == nill cancel the operation - if tmp.len == nil then return false, "No length specified." end + if not tmp.len then return false, "No length specified." end -- If ax1 is bad send "get" order if ax1 == "g" then tmp.get = true else vec[ax1] = sn1 * tmp.len end diff --git a/worldeditadditions_commands/commands/selectors/scube.lua b/worldeditadditions_commands/commands/selectors/scube.lua new file mode 100644 index 0000000..44f3258 --- /dev/null +++ b/worldeditadditions_commands/commands/selectors/scube.lua @@ -0,0 +1,55 @@ +-- ███████ ██████ ██ ██ ██████ ███████ +-- ██ ██ ██ ██ ██ ██ ██ +-- ███████ ██ ██ ██ ██████ █████ +-- ██ ██ ██ ██ ██ ██ ██ +-- ███████ ██████ ██████ ██████ ███████ +worldedit.register_command("scube", { + params = "[ [ []]] ", + description = "Set WorldEdit region position 2 at a set distance along 3 axes.", + privs = { worldedit = true }, + require_pos = 1, + parse = function(params_text) + local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} + local find = wea.split(params_text, "%s", false) + local ax1, ax2, ax3 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "g"):sub(1,1), + (tostring(find[3]):match('[xyz]') or "g"):sub(1,1) + local sn1, sn2, sn3, len = wea.getsign(find[1]), wea.getsign(find[2]), wea.getsign(find[3]), find[table.maxn(find)] + + tmp.len = tonumber(len) + -- If len is nill cancel the operation + if not tmp.len then return false, "No length specified." end + -- If axis is bad send "get" order + if ax1 == "g" then tmp.get = true + else vec[ax1] = sn1 * tmp.len end + if ax2 == "g" then tmp.get = true + else vec[ax2] = sn2 * tmp.len end + if ax3 == "g" then tmp.get = true + else vec[ax3] = sn3 * tmp.len end + + tmp.axes = ax1..","..ax2..","..ax3 + return true, vec, tmp + end, + func = function(name, vec, tmp) + if tmp.get then + local ax, dir = worldeditadditions.player_axis2d(name) + local _, left, sn = worldeditadditions.axis_left(ax,dir) + if not tmp.axes:find("x") then vec.x = tmp.len * (ax == "x" and dir or sn) end + if not tmp.axes:find("z") then vec.z = tmp.len * (ax == "z" and dir or sn) end + if not tmp.axes:find("y") then vec.y = tmp.len end + end + + local p2 = vector.add(vec,worldedit.pos1[name]) + worldedit.pos2[name] = p2 + worldedit.mark_pos2(name) + return true, "position 2 set to " .. minetest.pos_to_string(p2) + end, +}) + +-- Tests +-- /multi //fp set1 -63 19 -20 //scube 5 +-- /multi //fp set1 -63 19 -20 //scube z 5 +-- /multi //fp set1 -63 19 -20 //scube a z 5 +-- /multi //fp set1 -63 19 -20 //scube z a y 5 +-- /multi //fp set1 -63 19 -20 //scube -z y a 5 +-- /multi //fp set1 -63 19 -20 //scube z z 5 +-- /lua print() diff --git a/worldeditadditions_commands/commands/selectors/srect.lua b/worldeditadditions_commands/commands/selectors/srect.lua index 68af588..0c9353c 100644 --- a/worldeditadditions_commands/commands/selectors/srect.lua +++ b/worldeditadditions_commands/commands/selectors/srect.lua @@ -11,23 +11,26 @@ worldedit.register_command("srect", { parse = function(params_text) local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) - local ax1, ax2 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "y"):sub(1,1) + local ax1, ax2 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "g"):sub(1,1) local sn1, sn2, len = wea.getsign(find[1]), wea.getsign(find[2]), find[table.maxn(find)] tmp.len = tonumber(len) -- If len == nill cancel the operation - if tmp.len == nil then return false, "No length specified." end - -- If ax1 is bad send "get" order + if not tmp.len then return false, "No length specified." end + -- If axis is bad send "get" order if ax1 == "g" then tmp.get = true else vec[ax1] = sn1 * tmp.len end - vec[ax2] = sn2 * tmp.len + if ax2 == "g" then tmp.get = true + else vec[ax2] = sn2 * tmp.len end + tmp.axes = ax1..","..ax2 return true, vec, tmp end, func = function(name, vec, tmp) if tmp.get then local ax, dir = worldeditadditions.player_axis2d(name) - vec[ax] = tmp.len * dir + if not tmp.axes:find("[xz]") then vec[ax] = tmp.len * dir end + if not tmp.axes:find("y") then vec.y = tmp.len end end local p2 = vector.add(vec,worldedit.pos1[name]) diff --git a/worldeditadditions_commands/init.lua b/worldeditadditions_commands/init.lua index ff1b526..d5cfb3f 100644 --- a/worldeditadditions_commands/init.lua +++ b/worldeditadditions_commands/init.lua @@ -43,7 +43,7 @@ dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua") dofile(we_c.modpath.."/commands/selectors/scol.lua") dofile(we_c.modpath.."/commands/selectors/srect.lua") --- dofile(we_c.modpath.."/commands/selectors/scube.lua") +dofile(we_c.modpath.."/commands/selectors/scube.lua") dofile(we_c.modpath.."/commands/selectors/sstack.lua") dofile(we_c.modpath.."/commands/selectors/spush.lua") dofile(we_c.modpath.."/commands/selectors/spop.lua") From bdb51ff94449616b0edb1b1093f7368a6c413c62 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:44:27 -0800 Subject: [PATCH 4/6] Fix Typo Co-authored-by: Starbeamrainbowlabs --- worldeditadditions_commands/commands/selectors/scol.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua index 3e41dca..475aa92 100644 --- a/worldeditadditions_commands/commands/selectors/scol.lua +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -14,7 +14,7 @@ worldedit.register_command("scol", { local ax1, sn1, len = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), wea.getsign(find[1]), find[table.maxn(find)] tmp.len = tonumber(len) - -- If len == nill cancel the operation + -- If len == nil cancel the operation if not tmp.len then return false, "No length specified." end -- If ax1 is bad send "get" order if ax1 == "g" then tmp.get = true From ff9abded2e45d8733a8b9bf867aa83a22c9f9516 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 10 Mar 2021 20:56:38 -0800 Subject: [PATCH 5/6] localize wea --- worldeditadditions_commands/commands/selectors/scol.lua | 5 +++-- worldeditadditions_commands/commands/selectors/scube.lua | 7 ++++--- worldeditadditions_commands/commands/selectors/srect.lua | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua index 475aa92..08a2c36 100644 --- a/worldeditadditions_commands/commands/selectors/scol.lua +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -3,13 +3,14 @@ -- ███████ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ -- ███████ ██████ ██████ ███████ +local wea = worldeditadditions worldedit.register_command("scol", { params = "[] ", description = "Set WorldEdit region position 2 at a set distance along 1 axis.", privs = {worldedit=true}, require_pos = 1, parse = function(params_text) - local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} + local vec, tmp = vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) local ax1, sn1, len = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), wea.getsign(find[1]), find[table.maxn(find)] @@ -24,7 +25,7 @@ worldedit.register_command("scol", { end, func = function(name, vec, tmp) if tmp.get then - local ax, dir = worldeditadditions.player_axis2d(name) + local ax, dir = wea.player_axis2d(name) vec[ax] = tmp.len * dir end diff --git a/worldeditadditions_commands/commands/selectors/scube.lua b/worldeditadditions_commands/commands/selectors/scube.lua index 44f3258..b3d337e 100644 --- a/worldeditadditions_commands/commands/selectors/scube.lua +++ b/worldeditadditions_commands/commands/selectors/scube.lua @@ -3,13 +3,14 @@ -- ███████ ██ ██ ██ ██████ █████ -- ██ ██ ██ ██ ██ ██ ██ -- ███████ ██████ ██████ ██████ ███████ +local wea = worldeditadditions worldedit.register_command("scube", { params = "[ [ []]] ", description = "Set WorldEdit region position 2 at a set distance along 3 axes.", privs = { worldedit = true }, require_pos = 1, parse = function(params_text) - local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} + local vec, tmp = vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) local ax1, ax2, ax3 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "g"):sub(1,1), (tostring(find[3]):match('[xyz]') or "g"):sub(1,1) @@ -31,8 +32,8 @@ worldedit.register_command("scube", { end, func = function(name, vec, tmp) if tmp.get then - local ax, dir = worldeditadditions.player_axis2d(name) - local _, left, sn = worldeditadditions.axis_left(ax,dir) + local ax, dir = wea.player_axis2d(name) + local _, left, sn = wea.axis_left(ax,dir) if not tmp.axes:find("x") then vec.x = tmp.len * (ax == "x" and dir or sn) end if not tmp.axes:find("z") then vec.z = tmp.len * (ax == "z" and dir or sn) end if not tmp.axes:find("y") then vec.y = tmp.len end diff --git a/worldeditadditions_commands/commands/selectors/srect.lua b/worldeditadditions_commands/commands/selectors/srect.lua index 0c9353c..9c478fa 100644 --- a/worldeditadditions_commands/commands/selectors/srect.lua +++ b/worldeditadditions_commands/commands/selectors/srect.lua @@ -3,13 +3,14 @@ -- ███████ ██████ █████ ██ ██ -- ██ ██ ██ ██ ██ ██ -- ███████ ██ ██ ███████ ██████ ██ +local wea = worldeditadditions worldedit.register_command("srect", { params = "[ []] ", description = "Set WorldEdit region position 2 at a set distance along 2 axes.", privs = { worldedit = true }, require_pos = 1, parse = function(params_text) - local wea, vec, tmp = worldeditadditions, vector.new(0, 0, 0), {} + local vec, tmp = vector.new(0, 0, 0), {} local find = wea.split(params_text, "%s", false) local ax1, ax2 = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), (tostring(find[2]):match('[xyz]') or "g"):sub(1,1) local sn1, sn2, len = wea.getsign(find[1]), wea.getsign(find[2]), find[table.maxn(find)] @@ -28,7 +29,7 @@ worldedit.register_command("srect", { end, func = function(name, vec, tmp) if tmp.get then - local ax, dir = worldeditadditions.player_axis2d(name) + local ax, dir = wea.player_axis2d(name) if not tmp.axes:find("[xz]") then vec[ax] = tmp.len * dir end if not tmp.axes:find("y") then vec.y = tmp.len end end From 53d899b3fe6a176858494c9f2302545122e5936f Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 11 Mar 2021 12:59:04 -0800 Subject: [PATCH 6/6] commented tmp --- worldeditadditions_commands/commands/selectors/scol.lua | 3 +++ worldeditadditions_commands/commands/selectors/scube.lua | 4 ++++ worldeditadditions_commands/commands/selectors/srect.lua | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/worldeditadditions_commands/commands/selectors/scol.lua b/worldeditadditions_commands/commands/selectors/scol.lua index 08a2c36..37af6f4 100644 --- a/worldeditadditions_commands/commands/selectors/scol.lua +++ b/worldeditadditions_commands/commands/selectors/scol.lua @@ -22,6 +22,9 @@ worldedit.register_command("scol", { else vec[ax1] = sn1 * tmp.len end return true, vec, tmp + -- tmp carries: + -- The length (len) arguement to the main function for use if "get" is invoked there + -- The bool value "get" to tell the main function if it needs to populate missing information in vec end, func = function(name, vec, tmp) if tmp.get then diff --git a/worldeditadditions_commands/commands/selectors/scube.lua b/worldeditadditions_commands/commands/selectors/scube.lua index b3d337e..e7e38c9 100644 --- a/worldeditadditions_commands/commands/selectors/scube.lua +++ b/worldeditadditions_commands/commands/selectors/scube.lua @@ -29,6 +29,10 @@ worldedit.register_command("scube", { tmp.axes = ax1..","..ax2..","..ax3 return true, vec, tmp + -- tmp carries: + -- The length (len) arguement to the main function for use if "get" is invoked there + -- The bool value "get" to tell the main function if it needs to populate missing information in vec + -- The string "axes" to tell the main function what axes are and/or need to be populated if "get" is invoked end, func = function(name, vec, tmp) if tmp.get then diff --git a/worldeditadditions_commands/commands/selectors/srect.lua b/worldeditadditions_commands/commands/selectors/srect.lua index 9c478fa..7669100 100644 --- a/worldeditadditions_commands/commands/selectors/srect.lua +++ b/worldeditadditions_commands/commands/selectors/srect.lua @@ -26,6 +26,10 @@ worldedit.register_command("srect", { tmp.axes = ax1..","..ax2 return true, vec, tmp + -- tmp carries: + -- The length (len) arguement to the main function for use if "get" is invoked there + -- The bool value "get" to tell the main function if it needs to populate missing information in vec + -- The string "axes" to tell the main function what axes are and/or need to be populated if "get" is invoked end, func = function(name, vec, tmp) if tmp.get then