【发布时间】:2015-09-02 14:17:28
【问题描述】:
我在使用 Lua 中的 math.random() 函数时遇到问题。 我要运行的代码是:
for x = 1,5 do
math.randomseed(os.time())
math.random(); math.random(); math.random()
value = math.random(0,9)
print(value)
end
正在打印的随机数总是相同的。
对此有什么可能的解决方案?我想要 5 个唯一的随机数。
【问题讨论】:
-
把
math.randomseed(os.time())出循环