lua-users home
lua-l archive

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


>    The trouble is, when using Lua as a stand-alone, there's no good way to
> "randomly" seed the RNG -- date() returns a string,

If you call "date" with appropriate arguments, it returns a string in
numeric format, which is then converted to a number when used as argument
to randomseed. For instance, if you call

  randomseed(date"%H%M%S")

your seed is a concatenation of the current hour-minutes-seconds (pretty
close to "real" time for random purposes).

-- Roberto