My game needs (pseudo) random numbers to randomize things like which type of enemy appears, which type of item drops, etc.
In the simulator on my Mac , the following works as expected:
math.randomseed( socket.gettime() \* 10000 ) local rand = math.random()
Run about once a second, it prints out:
0.32544071754694 0.088621043175748 0.85180136880456 0.56267938928803 0.50969980820534 0.08904004054565
But when I run the same exact code on either of my Android devices (Nexus 7, Moto X), the output is always the same, no matter what I do. Even after a rebuild and re-install, it generates the exact same number on every iteration:
0.54531151640476
So I’m guessing it’s something with socket.getTime() returning the same value no matter what? If so, any suggestions for a better way to generate a seed that’s more granular than every second?