Jump to content

Math:Random repeats results


Powerhorst
 Share

Recommended Posts

Hey there!

 

Not entirely sure if this is just on my side, so feel free to delete this if I'm wrong.

 

I'm using Math:Random for my everyday needs in random numbers but it seems like I'm getting

the same numbers every time.

 

z = Math:Random(-10,10)

 

So even after restarting my project a few times, z always gets the same value.

The info-page states that LUA uses Math:Rnd instead but that just throws an error.

Sorry for the inconvenience if I'm just using it wrong but I can't find any other way so far.

 

 

Greets

Link to comment
Share on other sites

in the lua math module, its lower case:

z = math.random(-10,10)

but this will have the same effect as you are getting now that it returns the same number. To vary the returned number, use the random seed:

math.randomseed(Time:Millisecs())
z = math.random(-10,10)

see here for more details: http://www.lua.org/manual/5.1/manual.html#5.6

 

Edit- hankinator beat me to it smile.png

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

  • Admin locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...