Random...

Started by Yosha, September 25, 2015, 08:56:23 AM

Previous topic - Next topic
Hello, I don't know if anyone have already seen this, but I just saw yesterday that when I generate random numbers in a dialog, for each game I played, it was always the same numbers and in the same order...

Like in most languages, you need to initialize a different random seed if you want different sequences of numbers.
See http://www.lua.org/manual/5.1/manual.html#pdf-math.randomseed

Ok, thank you !
I use math.randomseed(os.time()) in map:on_started() and I have now a real random number !  :)

You don't need to do it in map:on_started(), but only once when your quest starts. So, in sol.main:on_started().