of     1   

doneyes
#102608763Monday, June 24, 2013 6:03 PM GMT

when I do this script, it only prints x as a whole number when x doesn't need to be rounded. So if x is 2.35678 and I run the math.random, it only returns 0,1, or 2. How can I get it to return to the nearest 10th of a decimal? x = mag * .08 print(x) x = math.random(0,x) print(x)
magnalite
#102609457Monday, June 24, 2013 6:07 PM GMT

When providing arguments to math.random() lua uses math.floor() on the first argument and math.ceil() on the second. It's essentially doing this behind the scenes. x = mag * .08 print(x) x = math.random(math.floor(0),math.ceil(x)) print(x) Way to get around this? Try multiplying x by a number to make it an integer then divide the result afterwards by the same number you multiplied it with. Good luck!
DigitalVeer
#102609582Monday, June 24, 2013 6:08 PM GMT

Maybe try dividing x at the end by a random variable. x = math.random(0,20) if x ~= 1 and x~= 0 then x = x/math.random(0,x) print(x) end That would surely return a random variable. However, I used to think that math.random would return decimals aswell. I'm pretty sure there is an easy way, after this I'ma just go look at the Wiki Page. You can also try putting one of the 2 parameters for math.random() as a decimal and see where that goes. Maybe try doing x = math.random(0,20.0) ^^ That normally is the case with Java, so you can go ahead and try that for all you want. Math.random is a very curious creature that I must hunt down! But first.... AMNESIA TIME ;D oh wow, how excited I feel coming back to this forum.

    of     1