home ~ projects ~ socials

Generate A Random Number Between To Integers In Lua

function random_int(min, max) 
  math.randomseed(os.time())
  print(math.random(min, max))
end

print(random_int(1, 4))
Output:
4

The min and max are inclusive. So:

random_int(3, 9)

Can return values of:

3, 4, 5, 6, 7, 8, 9

-- end of line --

References