jeudi 4 juin 2015

Lua 5.1.4 math.random not actually random

my problem is when i write math.random(10) it is not actually random it always give me output:

1 6 2 9

and if i have used for example:

local colors = {"ORANG","BLUE","RED","YELLOW","BLACK"}
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
print(colors[math.random(#colors)])
os.execute 'pause'

The output is always:

ORANGE
RED
ORANGE
BLACK
RED
RED
BLUE BLACK

This is always the output, how could it be random????




Aucun commentaire:

Enregistrer un commentaire