Difference between revisions of "love.math.setRandomSeed"
(Created page with "{{newin|0.9.0|090|type=function}} Seeds the random number generator with a specified number. == Function == === Synopsis === <source lang="lua"> love.math.randomseed( seed ) ...") |
m |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{newin|[[0.9.0]]|090|type=function}} | {{newin|[[0.9.0]]|090|type=function}} | ||
− | + | Sets the seed of the random number generator using the specified integer number. This is called internally at startup, so you generally don't need to call it yourself. | |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | love.math. | + | love.math.setRandomSeed( seed ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|number|seed|The number with which you want to seed the randomization.}} | + | {{param|number|seed|The integer number with which you want to seed the randomization. Must be within the range of [0, 2^53 - 1].}} |
=== Returns === | === Returns === | ||
Nothing. | 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 === | ||
+ | <source lang="lua"> | ||
+ | love.math.setRandomSeed( low, high ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|number|low|The lower 32 bits of the seed value. Must be within the range of [0, 2^32 - 1].}} | ||
+ | {{param|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 === | ||
+ | <source lang="lua"> | ||
+ | love.math.setRandomSeed(love.timer.getTime()) | ||
+ | </source> | ||
+ | |||
== See Also == | == See Also == | ||
* [[parent::love.math]] | * [[parent::love.math]] | ||
+ | * [[love.math.getRandomSeed]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description= | + | {{#set:Description=Sets the seed of the random number generator.}} |
== Other Languages == | == Other Languages == | ||
− | {{i18n|love.math. | + | {{i18n|love.math.setRandomSeed}} |
Latest revision as of 23:33, 4 May 2019
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. This is called internally at startup, so you generally don't need to call it yourself.
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