Created
November 2, 2022 14:47
-
-
Save kezzyhko/4bdf39b8a85e94ef53a3a9f9a067101e to your computer and use it in GitHub Desktop.
A function that returns a random integer from range [min; except) ∪ (except; max]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function RandomIntWithExcept(min: number, max: number, except: number?): number | |
if except then | |
local len = max - min + 1 | |
return (math.random(1, len-1) + except - min) % len + min | |
else | |
return math.random(min, max) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment