clamp

With this function you can maintain an input value between a specified range.

 

Syntax:

clamp(val, min, max)

ArgumentTypeDescription
valRealThe value to clamp.
minRealThe minimum value to clamp between.
maxRealThe maximum value to clamp between.

 

Returns:

Real

 

Example:

speed = clamp(speed, 1, 10);

The above code will clamp the speed so that it never falls below 1 or goes over 10.