math.random

From ComputerCraft
Jump to: navigation, search

math.random
Function
Syntax
math.random()
Returns number
API math
Source Lua (source)

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.

ExampleExamplePrint 5 random numbers
Code
for i = 1, 5 do
  print(math.random(1, 100))
end
Output Five lines with (probably) different, random numbers.