The clamp native AI script function is used to restrict a value between two limits. The function returns the value clamped between the two limits provided.
The low bound is the minimum value of the two limits provided, while the upper bound is the maximum value. If the input value is out of the specified bounds, the function returns the nearest limit value.
(clamped_value: f)clamp(value: f, lim1: f, lim2: f) // clamp_fff_f
value
clamped between lim1
and lim2
.(percentage)clamp(ratio, 0, 1)
This example code clamps the value of ratio
between 0 and 1, and stores the result in the variable percentage
.