From 533519d31878c31784c5c5b8515a31e14e48d5ff Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 5 Aug 2021 10:40:36 -0700 Subject: [PATCH] streamlined getsign --- worldeditadditions/utils/numbers.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/utils/numbers.lua b/worldeditadditions/utils/numbers.lua index 2bc93d1..0a6f159 100644 --- a/worldeditadditions/utils/numbers.lua +++ b/worldeditadditions/utils/numbers.lua @@ -82,9 +82,12 @@ 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 + if type(src) == "number" then + if src < 0 then return -1 else return 1 end elseif type(src) ~= "string" then return 1 - else return src:match('-') and -1 or 1 end + else + if src:match('-') then return -1 else return 1 end + end end --- Clamp a number to ensure it falls within a given range.