URX
|
  |
| Joined: 10 Nov 2009 |
| Total Posts: 1054 |
|
|
| 21 Apr 2014 01:33 PM |
If I did math.random(1,10), would there be a much easier way of checking individual values, than having to go if 1.... if 2.... if 3.... etc
Or could I condense it? Say if I want 6-10 to do the same? |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2014 01:35 PM |
math.randomseed(tick()) -- for better randomizing local num = math.random(1, 10) if num >= 6 then --do stuff end
#nerdsunited |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2014 01:35 PM |
tab = { [1] = '5' [2] = '5' [3] = '4' }
if tab[index] == something then --do stuff end
Hopefully you understand this and it helps. |
|
|
| Report Abuse |
|
|
Mlatu
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 540 |
|
|
| 21 Apr 2014 01:36 PM |
If you wanted 6-10 to do the same, then you need to find a similarity among those numbers. They are all greater than or equal to 6, and they will all be less than or equal to 10.
----------
randomNumber = math.random(1,10) if randomNumber >= 6 or randomNumber <=10 then --code end |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 21 Apr 2014 01:36 PM |
while true do wait(1) print(math.random(1,10)) end |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2014 01:36 PM |
mlatu, no need to check if it's smaller than 10 because it wont choose a number bigger than 10.
#nerdsunited |
|
|
| Report Abuse |
|
|
Mlatu
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 540 |
|
|
| 21 Apr 2014 01:37 PM |
| Well yes, in this case that applies, but I wanted to explain the concept instead of giving the man a fish. |
|
|
| Report Abuse |
|
|
URX
|
  |
| Joined: 10 Nov 2009 |
| Total Posts: 1054 |
|
| |
|