-
Notifications
You must be signed in to change notification settings - Fork 94
clamp
Ryzom Core Wiki edited this page Jul 8, 2024
·
4 revisions
title: Clamp description: published: true date: 2023-03-16T23:05:22.343Z tags: editor: markdown dateCreated: 2023-03-16T22:21:27.404Z
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 (float): The value to clamp.
- lim1 (float): The first clamp limit.
- lim2 (float): The second clamp limit.
-
clamped_value (float): The value of
value
clamped betweenlim1
andlim2
.
(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
.