Jump to content

math.random exclusions?


Recommended Posts

You'd need to make a new function for it. Something like:

-- Usage:  math.randomEx( 1, 10, 2,3,4,5,6 )
function math.randomEx( min, max, ... )
local bExcluded;
local iNum;
repeat
math.randomseed( getTickCount( ) );
       bExcluded = false;
       iNum = math.random( min, max );
for _, iVal in ipairs( arg ) do
if iNum == iVal then
               bExcluded = true;
break;
end
end
until not bExcluded;
return iNum;
end

NOT TESTED but should work.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...