Random 在Lua中设置随机种子
我想知道如何在Lua中使用Random 在Lua中设置随机种子,random,lua,Random,Lua,我想知道如何在Lua中使用math.randomseed。事实上,当用作函数时,我会得到一个错误,而当用作变量时,它就不起作用了 > math.randomseed = 0 > math.random() 0.51340090995654 > math.randomseed = 0 > math.random() 0.9522297247313 > math.randomseed (44) stdin:1: attempt to call a number valu
math.randomseed
。事实上,当用作函数时,我会得到一个错误,而当用作变量时,它就不起作用了
> math.randomseed = 0
> math.random()
0.51340090995654
> math.randomseed = 0
> math.random()
0.9522297247313
> math.randomseed (44)
stdin:1: attempt to call a number value (field 'randomseed')
stack traceback:
stdin:1: in main chunk
[C]: in ?
math.randomseed()
是存储在math
表中randomseed
名称下的函数
在您为randomseed
name下的math
表分配了一些值之后,您丢失了存储在那里的原始值—实际设置种子的函数。你不能执行这个数字,因为它不是一个函数
首先将调用math.randomseed()
作为函数,不要在那里分配数字