# Number methods

### Math: Variable Transition #

Transitions a variable (number) from a starting value to a final value over a given duration.
This command can act as a timer to trigger other commands or buttons.
For example, if you set the start value to 10, final value to 0 and duration to 10000ms (=10 seconds), it will decrease the value by 1 every second and reach 0 after exactly 10 seconds.

Box Name Type Description
Variable String Name of the variable.
Start Value Real (number) Starting point (where the counting starts from)
Final Value Real (number) Finishing point (where the counting stops at)
Allow Float boolean Float=values with decimal points, int=values without decimal points (rounded down)
Dur.(MS) Int Duration of the transition

### Math: Clamp #

Clamps a variable between two values. Intended to use on real values (numbers) only.

1. If value of the variable < minimum allowed value, returns minimum allowed value.
2. If value of the variable > maximum allowed value, returns maximum allowed value.
3. If value of the variable is within the allowed range, returns the original value.

Box Name Type Description
Variable String Name of the variable to clamp.
Min Real (number) Minimum value allowed.
Max Real (number) Maximum value allowed.
Value Clamp Min Clamp Max Result
20 50 120 50
75 50 120 75
980 50 120 120

### Math: Random #

Returns a variable with a random value (number) between minimum and maximum possible value.
This is a basic command you can use for showing random images, playing random videos/sounds, picking a random viewer from chat etc.
If you wish to have more power over randomizing values (like adding weights), it is best to use Stacks instead.

Box Name Type Description
Variable String Name of the variable to save the random value.
Min Real (number) Minimum value possible.
Max Real (number) Maximum value possible.
Float boolean True = random value returned can never be the maximum or minimum value itself
False = random value returned can be anything including maximum and minimum possible value
Any float value in minimum or maximum value is omitted if Float is set to False.

### Math: Hex to Real #

Converts a hexadecimal string into a real (decimal) number.

Box Name Type Description
Variable String Name of a variable to save the converted value.
Hex string value Returned real value
A 10
1d 29
1F4 500