From Second Life Wiki
Jump to navigation Jump to search

A function meant to generate a true random number (TRNG) in the interval [0, max) or (-max, 0] depending on the sign of max by grabbing bits from llGetRegionFPS as described in Wizardry and Steamworks/Randomness,_Entropy_and_Statistics.

<lsl> integer FPSrand(integer max) {

   integer r = (integer)(llGetRegionFPS() * 10000000.0) % max;
   if(max > 0) return r; else return -r;

} </lsl>