Code Exchange: Share Your Code with other Corona Developers

Share Your Code

Random generator engine cross-platform

Posted by josua, Posted on January 27, 2012

0 votes

Hello!

We have created this function for use on the daily challenge of our game MathCatch, because the random number generation on Android is different than IOS.

Use:

1
2
3
4
5
6
7
8
9
10
11
12
13
--declare the module:
urandom=require ("urandom")
 
--Call the random seed with:
urandom.RandomSeed( seed )
 
--seed = a number between 0 and 99999
 
--Obtain a random number with:
urandom.URandom (from, to)
 
--from = a number between 0 and 999999
--to = a number between 0 and 999999

Download from:
http://dl.dropbox.com/u/8768831/code/urandom.7z

If you use CPM, remember to manually add the file "rand" to assets.