Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 09 Jun 2014 11:43 PM |
How can I use math.random for numbers with decimals like
position = math.random(1, 3)
and have it go to positions like 1.439 or 2.4083 and stuff like that.
Is that possible with math.random or would I have to use something else? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 09 Jun 2014 11:46 PM |
| math.random() without any arguments, then just multiply that. |
|
|
| Report Abuse |
|
|
|
| 09 Jun 2014 11:46 PM |
| How about math.random() * math.random(1,3) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 09 Jun 2014 11:47 PM |
| There really is no point in multiplying the random number by a random number, but you could do that. |
|
|
| Report Abuse |
|
|
Kratos232
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 229 |
|
|
| 09 Jun 2014 11:49 PM |
By doing something like this:
local Number = math.random(10000, 30000) / 10000 You divide it to give decimals or it'd be giant.
or something like this: local Number = math.random() * math.random(1, 3)
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 09 Jun 2014 11:51 PM |
Why are you guys multiplying it by a random integer... Your 2 things do different things.
math.random() * 3
That isn't hard to do |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
| |
|
Kratos232
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 229 |
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 12:06 AM |
| And yours is not getting a random number between 0-3, more like between 0-1, 0-2, or 0-3 |
|
|
| Report Abuse |
|
|
| |
|