LyRandom - Ly Framework - Gamely

Create multiple independent and fast random number generators.
To access it from every script using Ly.Random LyFramework with properly setupped LyRequire is needed.
After installing you need to add it to LyFramework subfolder lib see LyRequire Documentation.

Sometime you need to have multiple generators everyone with its seed e.g. generate the same random number for every player without storing them.

Custom Random number generation faster than math.random.
Both Uniform distribution and fast Normal distribution ( really usefull for weapon spreads )

List of Functions.

Create(seed, [seed2]) Create a new Random number Generator with the provided seeds seeds2 is optional and set to default if not provided.

Next() Get a new floating point number from 0 and 1 using uniform distribution

NextInt(nMin , nMax) get new Integer number between min and max (uses min as max if max is not provided)

NextNormalDist() as Next but using normal distribution

NextNormalDistInt(nMin,nMax) as NextInt but using normal distribution

SetSeeds(seed , [seed2]) sets a new seeds for this generator seed2 is optional and set to default if not provided

GetSeeds() returns 2 seeds (to clone , rollback or serializing the generator paired with Setseeds or Create)

Shuffle(t) Shuffles the provided array and returns it back.

UniqueIntList(n, minimum, maximum , tOut) Get an array of n unique ints from min to overwriting tOut or in a new array if tOut is not provided. IMPORTANT Does not resize tOut.

1 Like