mercredi 2 septembre 2015

Lua random number generation

I am having trouble with the math.random() function in Lua. The code I'm trying to run is:

 for x = 1,5 do
    math.randomseed(os.time())
    math.random(); math.random(); math.random()
    value = math.random(0,9)
    print(value)
end

The random number that is being printed is always the same.

What can be the possible solution to this? I want 5 unique random numbers.




Aucun commentaire:

Enregistrer un commentaire