From 77ffda46f78904ffa050a4c38af454dd8204ba3e Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Mon, 2 Aug 2021 18:16:50 -0700 Subject: [PATCH] added axis and dir checks --- .../lib/selection/selection.lua | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/worldeditadditions/lib/selection/selection.lua b/worldeditadditions/lib/selection/selection.lua index 299fe1b..e32fc08 100644 --- a/worldeditadditions/lib/selection/selection.lua +++ b/worldeditadditions/lib/selection/selection.lua @@ -8,9 +8,9 @@ local selection = {} --- Additively adds a point to the current selection or --- makes a selection from the provided point. --- @param name string Player name. --- @param pos vector The position to include. +-- makes a selection from the provided point. +-- @param name string Player name. +-- @param pos vector The position to include. function selection.add_point(name, pos) if pos ~= nil then -- print("[set_pos1]", name, "("..pos.x..", "..pos.y..", "..pos.z..")") @@ -36,7 +36,7 @@ function selection.add_point(name, pos) end --- Clears current selection. --- @param name string Player name. +-- @param name string Player name. function selection.clear_points(name) worldedit.pos1[name] = nil worldedit.pos2[name] = nil @@ -46,4 +46,23 @@ function selection.clear_points(name) worldedit.player_notify(name, "Region cleared") end +--- Checks if a string is a valid axis. +-- @param str string String to check (be sure to remove any + or -). +-- @param hv bool Include "h" (general horizontal) and "v" (general vertical). +-- @return bool If string is a valid axis then true. +function selection.check_axis(str,hv) + if hv then + return (str == "x" or str == "y" or str == "z" or str == "h" or str == "v") + else + return (str == "x" or str == "y" or str == "z") + end +end + +--- Checks if a string is a valid dir. +-- @param str string String to check (be sure to remove any + or -). +-- @return bool If string is a valid dir then true. +function selection.check_dir(str) + return (str == "front" or str == "back" or str == "left" or str == "right" or str == "up" or str == "down") +end + return selection