标签: random lua random-seed
我一直在使用Lua生成随机数一段时间了。我尝试用math.randomseed(os.time())启动脚本,我仍然得到相同的结果。每次运行脚本时,如何让下面的脚本生成一个新的随机数?
function rand() local x = math.random(1, #Questions) --Pick a random question from a table return x end
答案 0 :(得分:0)
这是well known problem。在程序中使用结果之前,只需拨打math.random一次或两次即可。
math.random