lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

I could not understand how to get a trully randomic integer. Suppose I need 50 randomic integers each time I call a function. Serching in documentation, I found two functions in Math module: math.random and math.randomseed.

The first one is not what I want. Calling it, I got always the same 50 numbers. In Pascal, before using random functions, it's necessary to call "randomize" which starts the randomic number generator. I don't know if it's also necessary in Lua.

But I try to use math.randomseed. The first tesst is:

print(math.randomseed(100))

print(math.randomseed(0, 100))

Despite no errors, I dindn't get anything. So I ask: how to obtain 50 different integers each time I call the randoms functions?

Luciano de Souza