math.randomseed
Sets the seed for the random number generator used by math.random. The same seeds produce will always produce the same random numbers.
|
|||
| Print two sequences of randomly generated numbers using the same seed | |||
| Code | <nowiki>
math.randomseed(1234)
print("First: " .. math.random())
math.randomseed(1234)
print("Second: " .. math.random())
</nowiki>
|
||
| Output | First: 0.12414929654836 Second: 0.12414929654836 |
||
Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Lua |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CC:Tweaked |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| math.randomseed Function | |
|---|---|
|
Syntax math.randomseed(
| |
| Returns | nil |
| API | math |
| Source | Lua (source) |
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.