math.random
If neither min nor max were given, return a random floating point number between 0 and 1. If only min was given, return it; Otherwise, return a random integer between min and max.
|
|||
| Code | <nowiki>
for i = 1, 5 do
print(math.random(1, 100))
end
</nowiki>
|
||
| Output | Five lines with (probably) different, random numbers. | ||
Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Lua |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CC:Tweaked |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| math.random Function | |
|---|---|
|
Syntax math.random(
| |
| Returns | number |
| 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.