• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Simple question about math.random

  • Thread starter Thread starter Deleted member 141899
  • Start date Start date
D

Deleted member 141899

Guest
Hello, what a % of chance is it?

if math.random(1000) > 50 then

i don't understand.

Thanks.
 
math.random returns a random number between 0.00000000000001 and 1 when no argument is used or 1 and the max value passed to math.random (max value you can pass is 999999999999999999).

However although math.random will return a decimal number when no argument is passed to math.random, you may only pass math.random an argument which is a whole number (e.g. 1, 2, 3 etc) otherwise you will generate an error.

You can also pass 2 arguments to math.random
Code:
-- math.random(min, max)
math.random(10, 20)


You can test your condition on this site
http://www.lua.org/cgi-bin/demo

Just copy the code into the box and hit run
Code:
x = math.random(1000)
print(x > 50, x)
 
Last edited:
Back
Top