lua-users home
lua-l archive

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



On May 24, 2006, at 11:02, Beric Holt wrote:

I've just finished upgrading my TileEngine game platform to use Lua
v5.1.

Everything is working fine, in fact I've even added better error
handling while loading scripts instead of using the old lua_dofile
syntax.  The only problem is that math.random() always returns zero,
even when called with parameters eg:
iResult = math.random(750,2000)

I use the random functionality for my Actor AI, so when it returns zero
all of the actors just stand there mutely.

I have randomised the seed with "math.randomseed( os.time())".

Does anyone have any suggestions on why this might be happening?

Check that rand() is implemented properly on your platform. math.random calls rand from the standard C library.

People that care about using random numbers usually replace math.rand, I recommend a combined tausworthe generator.


drj