I have the following code:
APP.logevent('ostime:'..os.time())
APP.logevent('random:'..math.random())
APP.logevent(math.randomseed(os.time()))
When i check my logs, this is what I get:
Tue Feb 5 11:49:53 2013: ostime:1360082993
Tue Feb 5 11:49:53 2013: random:0.84018771715471
Tue Feb 5 11:49:53 2013:
machinename:/usr/share/ajj#
I’m not getting any error messages….
Can you tell me why the call to randomeseed() is failing?
I’ve also tried replacing the call to “os.time()” in the randomseed with a number… and that doesn’t seem to work either.
Thanks.
It’s not supposed to. Lua functions are not required to return a values, and there’s no real reason for randomseed to return anything.
It’s not.
EDIT:
That’s what
math.randomdoes.randomseedseeds the random number generator, which is to say it sets an initial value that the pseudorandom number generator uses to find the next pseudorandom value. For a given seed (including the default seed, i.e. you never callrandomseed), you’ll get the same list of pseudorandom values back every time.