|
| 27 Sep 2014 05:08 PM |
| Ello. I was wondering if a number would pick randomly 1-10. Since I want it to do it 2 times, how do I make it so it does not pick the same number? |
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 27 Sep 2014 05:09 PM |
local x = math.random(1, 10) local y repeat y = math.random(1, 10) until x ~= y
~Jode |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 27 Sep 2014 05:16 PM |
math.randomseed(os.time());math.random(); math.random(); math.random() -- Because math.random() tends to produce equal sequences of numbers
a = math.random(1,10)
print(a) -- 5
b = math.random(1,10)
print(b) -- 2 |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2014 05:35 PM |
a=math.random(1,10) b=math.random(1,10) repeat b=math.random(1,10) until a ~= b
print('First number:'..tostring(a)..' Second number:'..tostring(b)) |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2014 05:37 PM |
local a = math.random(10) local b; repeat b = math.random(10) until b ~= a
-ForeverDev |
|
|
| Report Abuse |
|
|
| |
|