lovr.math.random

Returns a uniformly distributed pseudo-random number. This function has improved randomness over Lua's math.random and also guarantees that the sequence of random numbers will be the same on all platforms (given the same seed).

Generate a pseudo-random floating point number in the range [0,1)

x = lovr.math.random()

Arguments

None

Returns

NameTypeDescription
xnumberA pseudo-random number.

Generate a pseudo-random integer in the range [1,high]

x = lovr.math.random(high)

Arguments

NameTypeDescription
highnumberThe maximum number to generate.

Returns

NameTypeDescription
xnumberA pseudo-random number.

Generate a pseudo-random integer in the range [low,high]

x = lovr.math.random(low, high)

Arguments

NameTypeDescription
lownumberThe minimum number to generate.
highnumberThe maximum number to generate.

Returns

NameTypeDescription
xnumberA pseudo-random number.

Notes

You can set the random seed using lovr.math.setRandomSeed.

See also