TorqueScript Reference
|
Functions | |
Float | getRandom ([min]?,[max]?) |
Integer | getRandomBell (min, max, [mean]?, [stdDev]?) |
Float | getRandomF (min, max) |
Integer | getRandomSeed () |
F32 | mRandF (const F32 f1, const F32 f2) |
S32 | mRandI (const S32 i1, const S32 i2) |
void | setRandomSeed (startSeed) |
Float getRandom | ( | [ min ] ? | , |
[ max ] ? | |||
) |
Use the getRandom function to get a random floating-point or integer value. This function comes in three forms. The first getRandom() takes no arguments and will return a random floating-point value in the range of 0.0 to 1.0. The second getRandom( max ) takes one argument representing the max integer value this will return. It will return an integer value between 0 and max. The third getRandom( min , max ) takes two arguments representing the min and max integer values this will return. It will return an integer value between min and max. Only the no-args version will return a floating point.
min | Minimum inclusive integer value to return. |
max | Maximum inclusive integer value to return. |
Integer getRandomBell | ( | min | , |
max | , | ||
[ mean ] ? | , | ||
[ stdDev ] ? | |||
) |
Gets a random integer number with normal distribution (a bell curve) from min to max with optional mean and standard deviation.
min | The minimum range of the random integer number. |
max | The maximum range of the random integer number. |
mean | The Most commonly occuring value or the center of the "bell". Must be between the min and max. Defaults to the center value between min and max. |
stdDev | The standard deviation affects how far values tend to be from the mean. Defaults to 1/6th of the difference between min and max. |
Float getRandomF | ( | min | , |
max | |||
) |
Gets a random floating-point number from min to max.
min | The minimum range of the random floating-point number. |
max | The maximum range of the random floating-point number. |
Integer getRandomSeed | ( | ) |
Use the getRandomSeed function to get the current seed for the random generator. You can re-seed the generator with this value to allow you to recreate a random sequence. Merely save the seed and execute your random sequence. Later, to reproduce this sequence re-seed the generator with setRandomSeed and your saved value. Then, the generator will produce the same random sequence that followed the call to getRandomSeed.
F32 mRandF | ( | const F32 | f1, |
const F32 | f2 | ||
) |
S32 mRandI | ( | const S32 | i1, |
const S32 | i2 | ||
) |
void setRandomSeed | ( | startSeed | ) |
Use the setRandomSeed function to initialize the random number generator with the initial seed of startSeed.
startSeed | The new starting seed value for the random generator. |