lua-users home
lua-l archive

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


Beric,

I experienced the exact same thing when I upgraded InkSpector
(Windows/DirectX) from Lua 5.0 to 5.1. By using the
D3DCREATE_FPU_PRESERVE option when creating the D3D device, the
math.random problem vanished.

View this message for more info
http://lua-users.org/lists/lua-l/2006-01/msg00348.html

Cheers,
Mark.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Beric Holt
Sent: 24 May 2006 11:03
To: Lua list
Subject: Math.Random() always returns 0

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?

Thanks
Beric Holt
Soap Dragon
http://buzzrick.emedia.net.nz