# Get random

## Syntax

Syntax: get_random register 1, register 2

• register 1 = Start of continuous registers to determine the lowest and highest possible values.
• register 2 = Register that will contain your returned random number.

## Random number generator

Random number generator generates a random number. To use the random number generator make a new function. Then leti register 121 to equal the maximum value that you want it to be (note maximum valid value is 10,000 in dec.) Then call function 230 and end with a ret. Your returned random number will be between 1 and the maximum value you stated in register 121, your random number will be stored in register 122.

## Use

Used to generate a random number.

## How the function appears in the script

```
100:     leti R121, 00002710 //Makes register 121 equal 00002710. (10000 dec.)
call 230 //Calls function 230.
ret
230:     leti R120, 00000000 //Makes register 120 equal 00000000.
sync  //Waits 1 frame.
gettime R123 //Stores the current number of frames in the day in register 123.
clear R122 //Makes register 122 equal 00000000.
get_random R120, R122 //Gets a random number between the value of register 120 , and the value of register 121. Then stores the returned random number in register 122.
sub R123, R122 //Subtracts the value of register 122 from the value of register 123 and stores the result in register 123.
let R122, R123 //Makes the value of register 122 equal the value of register 123.
sub R121, R120 //Subtracts the value of register 120 from the value of register 121 and stores the result in register 121.
div R123, R121 //Divides the value of register 123 by the value of register 121 and stores the result in register 123.
mul R123, R121 //Multiplies the value of register 123 by the value of register 121 and stores the result in register 123.
sub R122, R123 //Subtracts the value of register 123 from the value of register 122 and stores the result in register 122.
add R122, R120 //Adds the value of register 120 to the value of register 122 and stores the result in register 122.