Skip to reading
PCA Script Programming

clamp()

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page
Code example
clamp(value, minimum, maximum)

Keep a numeric value inside a limit.

Returns: Number between the supplied limits.

Code example
clamp(120, 0, 100)

lerp()#

Code example
lerp(start, finish, weight)

Interpolate two numbers. A weight of 0 chooses start; 1 chooses finish.

Returns: Number.

Code example
lerp(10, 20, 0.25)

The helper is numeric, not a vector or color interpolation API. Clamp weight yourself if extrapolation is unwanted.

distance()#

Code example
distance(a, b)

Measure two Vector2 values, two Vector3 values, or the absolute difference of two numbers.

Returns: Number; 0 for unsupported pairs.

Code example
distance(vector3(0, 0, 0), vector3(3, 0, 4))

Do not pass character references and expect positions to be discovered automatically.

random_int() and aliases#

Code example
random_int(minimum, maximum)

Choose a whole number, including both endpoints.

Returns: Integer.

Aliases: random_integer()

Code example
random_int(1, 6)
Page 55 of 357Permalink
Go to page