mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
streamlined getsign
This commit is contained in:
parent
e5443bc3ce
commit
533519d318
1 changed files with 5 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue