lovr.math.newRandomGenerator

Creates a new RandomGenerator, which can be used to generate random numbers. If you just want some random numbers, you can use lovr.math.random. Individual RandomGenerator objects are useful if you need more control over the random sequence used or need a random generator isolated from other instances.

Create a RandomGenerator with a default seed.

randomGenerator = lovr.math.newRandomGenerator()

Arguments

None

Returns

NameTypeDescription
randomGeneratorRandomGeneratorThe new RandomGenerator.

randomGenerator = lovr.math.newRandomGenerator(seed)

Arguments

NameTypeDescription
seednumberThe initial seed for the RandomGenerator.

Returns

NameTypeDescription
randomGeneratorRandomGeneratorThe new RandomGenerator.

This variant allows creation of random generators with precise 64-bit seed values, since Lua's number format loses precision with really big numbers.

randomGenerator = lovr.math.newRandomGenerator(low, high)

Arguments

NameTypeDescription
lownumberThe lower 32 bits of the seed.
highnumberThe upper 32 bits of the seed.

Returns

NameTypeDescription
randomGeneratorRandomGeneratorThe new RandomGenerator.

See also