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
randomGeneratorRandomGenerator The new RandomGenerator.

randomGenerator = lovr.math.newRandomGenerator(seed)

Arguments

NameTypeDescription
seednumber The initial seed for the RandomGenerator.

Returns

NameTypeDescription
randomGeneratorRandomGenerator The 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
lownumber The lower 32 bits of the seed.
highnumber The upper 32 bits of the seed.

Returns

NameTypeDescription
randomGeneratorRandomGenerator The new RandomGenerator.

See also