Difference between revisions of "LlFrand"

From Second Life Wiki
Jump to navigation Jump to search
m (LlFrand moved to LSL llFrand)
(Example shows how to use llFrand to simulate tossing a fair coin.)
Line 11: Line 11:
|spec=returns random number in range [0.0, mag) or (mag, 0.0]; depending upon the sign of mag.
|spec=returns random number in range [0.0, mag) or (mag, 0.0]; depending upon the sign of mag.
|caveats
|caveats
|examples
|examples=
<lsl>
default
{
    touch_start(integer total_number)
    {
        // When touched, say "Heads" with probability 0.5,
        // otherwise, say "Tails."
        if ( llFrand(1.) < .5)
            llSay(0, "Heads");
        else
            llSay(0, "Tails");
    }
}
</lsl>
 
|func_helpers
|func_helpers
|also
|also

Revision as of 12:38, 27 January 2007

   Outdated templated used

Please change the template from 'LSLFunctionAll' to 'LSL_Function' (just replace 'LSLFunctionAll' with 'LSL_Function', do this after fixing any other erorr messages.

Summary

Function: float llFrand( float mag );

Returns a float that is random and in the range [0.0,mag) or (mag, 0.0].

• float mag Any valid float value

Specification

returns random number in range [0.0, mag) or (mag, 0.0]; depending upon the sign of mag.

Examples

<lsl> default {

   touch_start(integer total_number)
   {
       // When touched, say "Heads" with probability 0.5, 
       // otherwise, say "Tails."
       if ( llFrand(1.) < .5)
           llSay(0, "Heads");
       else
           llSay(0, "Tails");
   }

}

</lsl>

Deep Notes

Search JIRA for related Issues

Signature

function float llFrand( float mag );