Available since LÖVE 0.9.1 |
This function is not supported in earlier versions. |
Gets the current state of the random number generator. This returns an opaque string which is only useful for later use with RandomGenerator:setState in the same major version of LÖVE.
This is different from RandomGenerator:getSeed in that getState gets the RandomGenerator's current state, whereas getSeed gets the previously set seed number.
state = RandomGenerator:getState( )
None.
string state
The value of the state string does not depend on the current operating system.
rng = love.math.newRandomGenerator(os.time()) for i=1, 100 do -- Use some random numbers. rng:random() end -- Make a new RandomGenerator and set its state to the current state of the first one. rng2 = love.math.newRandomGenerator() rng2:setState(rng:getState()) -- Both 'rng' and 'rng2' will now give the same results. assert(rng:random() == rng2:random())