Skip to main content

.clamp()

A function that constrains a value within a specified range, ensuring that a value stays within a minimum and maximimum value (inclusive).

Syntax

return #fs.scripts.lib().clamp(0, 5, 10);

Parameters

Value

The value to be constrained.

Min

The minimum number the value should be constrained to.

Max

The maximimum number the value should be constrained to.

Return

Returns a number.

5

Example

function(context, args) {
const l = #fs.scripts.lib();
return l.clamp(0, 5, 10);
}