XxHAMADEHxX wrote:I only get the first argument.
What exactly do you mean by this? that the love.math.random(20,300) call returns 20 always, or that you only understand what the first argument is supposed to mean?
In any case, love.math.random has 3 "forms":
Code: Select all
love.math.random() -- returns a (real) number between 0 and 1, inclusive, uniformly distributed.
love.math.random(max) -- returns a (whole) number between 0 and max, inclusive, uniformly distributed.
love.math.random(min,max) -- returns a (whole) number between min and max, inclusive, uniformly distributed.
-- and if you want any other type, like, a real number between min and max, you might do it like this:
function myrandom(min, max)
min, max = math.min(min, max), math.max(min, max)
return -min + love.math.random() * (min+max)
I will guess i don't need to explain what real and whole numbers mean, inclusive is that it can return the numbers you gave it as limits (or 0 and 1 in the first case), and it being uniformly distributed just means there's an equal chance to get any value.
Just like lua's math.random, except löve's has more consistent output across platforms, and lua's is not seeded when the program starts up, so you're bound to get the same output always.