mercredi 10 octobre 2018

Lua Random number generator always produces the same number

I have looked up several tutorials on how to generate random numbers with lua, each said to use math.random(), so I did. however, every time I use it I get the same number every time, I have tried rewriting the code, and I always get the lowest possible number. I even included a random seed based on the OS time. code below.

require "math"
math.randomseed(os.time())
num = math.random(0,10)
print(num)




Aucun commentaire:

Enregistrer un commentaire