Available since LÖVE 0.9.0
This function is not supported in earlier versions.
Generates a pseudo-random number in a platform independent manner. This function is seeded at startup, so you generally don't need to seed it yourself.
Get uniformly distributed pseudo-random real number within [0, 1].
number = love.math.random( )
None.
number numberGet a uniformly distributed pseudo-random integer within [1, max].
number = love.math.random( max )
number maxnumber numberGet uniformly distributed pseudo-random integer within [min, max].
number = love.math.random( min, max )
number minnumber maxnumber numberGenerates a number between 1 and 100 (both inclusive).
function love.load()
randomNumber = love.math.random(1, 100)
end When using the 2nd and 3rd variant, numbers passed will be rounded, thus, love.math.random(0, 76.767) may return 77
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.math.random