Circular Index

Pure
CircularIndex

Wraps an index to stay within array bounds (handles negative indices too).

Type: Pure (no side effects)
Category: Fortuna|Array & Collection
Keywords: array & collection

Inputs

NameTypeDefaultDescription
IndexintIndex parameter
ArrayLengthintArrayLength parameter

Outputs

NameTypeDescription
ReturnValueintReturnValue output

Example Use Cases

Example 1

Implement a circular menu that wraps around.

Example 2

Cycle through weapon slots continuously.