modding:function:random
Discuss this page on this page's Talk Page
random
Syntax | (random expression1 [number]) → expression2 |
---|---|
Arguments | expression1 : A list or number. |
number: Optional. The number you want to a random number between them the second must be greater than the first number. | |
Returns | expression2: If the expression1 argument is a list it returns a random element of the list, if the expression1 is a number then returns a number between the expression1 number and optional number. |
random |
Description | If the expression argument is a list it returns a random element of the list, if the expression is a number then returns a number between the expression number and optional number. |
---|
Very useful function for making variation in code.
Example
(random 4)
Returns 4. Pretty much a useless bit of code, but it works.
(random 1 10)
Can return any number from 1 to 10, like 3. The range of possible numbers is 1-10.
(random 6 10)
Returns a number from 6 to 10, like 9. The range of possible numbers is 6-10.
(random '(a b c d))
Can return any element in the list '(a b c d).
Return to Functions list
modding/function/random.txt · Last modified: 2014/12/27 04:40 by 127.0.0.1