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
xnumber A pseudo-random number.

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

x = lovr.math.random(high)

Arguments

NameTypeDescription
highnumber The maximum number to generate.

Returns

NameTypeDescription
xnumber A pseudo-random number.

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

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

Arguments

NameTypeDescription
lownumber The minimum number to generate.
highnumber The maximum number to generate.

Returns

NameTypeDescription
xnumber A pseudo-random number.

Notes

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

See also