Difference between revisions of "love.math.setRandomSeed"
(If we're going to show an example that uses time as a seed, at least use a high resolution timer) |
|||
Line 24: | Line 24: | ||
Nothing. | Nothing. | ||
== Examples == | == Examples == | ||
− | === Set a | + | === Set a random seed === |
<source lang="lua"> | <source lang="lua"> | ||
− | love.math.setRandomSeed( | + | love.math.setRandomSeed(love.timer.getTime()) |
</source> | </source> | ||
Revision as of 14:56, 4 October 2017
Available since LÖVE 0.9.0 |
This function is not supported in earlier versions. |
Sets the seed of the random number generator using the specified integer number.
Contents
Function
Synopsis
love.math.setRandomSeed( seed )
Arguments
number seed
- The integer number with which you want to seed the randomization. Must be within the range of [0, 2^53 - 1].
Returns
Nothing.
Notes
Due to Lua's use of double-precision floating point numbers, integer values above 2^53 cannot be accurately represented. Use the other variant of the function if you want to use a larger number.
Function
Combines two 32-bit integer numbers into a 64-bit integer value and sets the seed of the random number generator using the value.
Synopsis
love.math.setRandomSeed( low, high )
Arguments
number low
- The lower 32 bits of the seed value. Must be within the range of [0, 2^32 - 1].
number high
- The higher 32 bits of the seed value. Must be within the range of [0, 2^32 - 1].
Returns
Nothing.
Examples
Set a random seed
love.math.setRandomSeed(love.timer.getTime())
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info