monday Posted November 5, 2014 Posted November 5, 2014 Hi, is there any simple way to get a random number out of 150 numbers I previously defined? Let's say I have numbers like: 1,3,10,25,26,84,90,111,160, 209,260,302,381 Is there any: num = math.randomfrom(1,3,10,25,26,84,90,111,160, 209,260,302,381) --or num = math.random(1,381, [except 2,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,27...]) Or is it necessary to make a lot of conditions like: if num > A and num < than B
pa3ck Posted November 5, 2014 Posted November 5, 2014 Are you looking for something like this? local numbers = { 25, 27, 31, 44, 55 } -- define the numbers local randomC = math.random ( 1, #numbers ) outputChatBox ( numbers [ randomC ] )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now