Skip to content

Instantly share code, notes, and snippets.

@kezzyhko
Created November 2, 2022 14:47
Show Gist options
  • Save kezzyhko/4bdf39b8a85e94ef53a3a9f9a067101e to your computer and use it in GitHub Desktop.
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]
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