|
| 23 May 2013 06:27 PM |
i know how to use math.Random with strings in a table but how can you make it so that it chooses a certain number within a certain range. i need this for an RPG project im working on.
please help me |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:28 PM |
a = math.random(1,1337) if a == 1337 then print 'that was cool' |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:37 PM |
thanks! so say i wanted a number to be multiplied by a certain percent i would do
x = math.random(0.5, 1) b = DmgAverage*x
??? |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 06:41 PM |
| its not working the damage comes up either as 200 or zero. does the 0.5 count as a zero? and why does it not do any decimals in between? |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:43 PM |
| In math.random the smaller number has to go first. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:44 PM |
oops didnt realise you were.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 06:45 PM |
while wait(0.1) do print(math.random(0.5, 1) end
post output |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:49 PM |
the output says 0 1 0 1 1 1 0 0 1 0 1 0 1 1 0 0 0 0 1 etc. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:51 PM |
thats why.
do you know math?
|
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 23 May 2013 06:52 PM |
math.random does not accept decimal values. Floats, if you like.
while wait(0.1) do print(math.random(5, 10)/10) end |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:57 PM |
| Pokemon yes i know math. im in 7th grade and in advanced math i should know it by now. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:58 PM |
| good idea MrNicNac it worked. i wish i had thought of doing that. |
|
|
| Report Abuse |
|
|
vulture97
|
  |
| Joined: 09 Feb 2009 |
| Total Posts: 1589 |
|
|
| 23 May 2013 07:03 PM |
Use math.random(5,10) instead of math.random(0.5,1), and divide it by ten.
Example:
x = math.random(5,10) print (x/10)
The output should then read between .5 and 1. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 07:08 PM |
| thank you but someone above took care of it already. |
|
|
| Report Abuse |
|
|