From 16b7748ac6a8ccab6a223e7bcadf405051d0921c Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Fri, 25 Jun 2021 18:12:30 -0700 Subject: [PATCH] some refactoring and commenting in smake --- .../commands/selectors/smake.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/worldeditadditions_commands/commands/selectors/smake.lua b/worldeditadditions_commands/commands/selectors/smake.lua index 46f1c64..03c062a 100644 --- a/worldeditadditions_commands/commands/selectors/smake.lua +++ b/worldeditadditions_commands/commands/selectors/smake.lua @@ -67,10 +67,15 @@ worldedit.register_command("smake", { return true, oper, mode, targ, base end, func = function(name, oper, mode, targ, base) - local p1, p2, eval = vector.new(worldedit.pos1[name]), vector.new(worldedit.pos2[name]), function(int) return int or 0 end - local delta, _tl, targ, _m = vector.subtract(p2,p1), #targ, wea.tocharset(targ), 0 -- local delta equation: Vd(a) = V2(a) - V1(a) + local p1, p2, = vector.new(worldedit.pos1[name]), vector.new(worldedit.pos2[name]) + local eval = function() end -- Declare eval placeholder function to edit later - -- set _m to the max, min or mean of the target axes depending on mode (_tl is the length of targ) or base if it exists + local delta = vector.subtract(p2,p1) -- local delta equation: Vd(a) = V2(a) - V1(a) + local _tl = #targ -- Get targ length as a variable incase mode is "average"/"avg" + local targ = wea.tocharset(targ) -- Break up targ string into set table + local _m = 0 -- _m is the container to hold the max, min or average (depending on the mode) of the axes in targ targ + + -- set _m to the max, min or mean of the target axes depending on mode or base if it exists if base then _m = delta[base] elseif mode == "avg" then for k,v in pairs(targ) do _m = _m + math.abs(delta[k]) end