Shared

arrayContains

fjsf.arrayContains(inputArray, targetValue)

Checks if a value exists inside an array. Intended only for sequential tables (1..n).

Parameters

  • inputArray (table) β€” The array to search

  • targetValue (any) β€” The value to look for

Returns

  • (boolean) β€” true if the value exists, otherwise false

Example

if fjsf.arrayContains(allowedJobs, playerJob) then
    openMenu()
end

arrayAt

fjsf.arrayAt(inputArray, position)

Returns the element at the given index. Negative indexes are supported (-1 returns the last element).

Parameters

  • inputArray (table) β€” The array to read from

  • position (number) β€” The index to access

Returns

  • (any | nil) β€” The element at the index or nil

Example


arrayForEach

Iterates over an array and executes a callback for each element.

Parameters

  • inputArray (table) β€” The array to iterate

  • iterator (function) β€” Function called with (value, index)

  • iterateReverse (boolean) β€” Whether to iterate backwards

Returns

  • (nil)

Example


arrayMap

Creates a new array by transforming each element.

Parameters

  • sourceArray (table) β€” The array to map

  • mapper (function) β€” Function (value, index, sourceArray)

Returns

  • (table) β€” A new mapped array

Example


arrayFind

Returns the first element that matches a condition.

Parameters

  • sourceArray (table) β€” The array to search

  • predicate (function) β€” Function (value, index) returning boolean

  • reverse (boolean) β€” Whether to search from the end

Returns

  • (any | nil) β€” The found element or nil

Example


arrayFindIndex

Returns the index of the first element matching a condition.

Parameters

  • sourceArray (table) β€” The array to search

  • predicate (function) β€” Function (value, index)

  • reverse (boolean) β€” Whether to search from the end

Returns

  • (number | nil) β€” The index or nil

Example


arrayFilter

Creates a new array containing only elements that pass a condition.

Parameters

  • sourceArray (table) β€” The array to filter

  • predicate (function) β€” Function (value, index)

Returns

  • (table) β€” Filtered array

Example


arrayMerge

Combines multiple arrays into a single new array.

Parameters

  • ... (table) β€” Arrays to merge

Returns

  • (table) β€” New merged array

Example


arrayPop

Removes and returns the last element of an array.

Parameters

  • inputArray (table) β€” The array to modify

Returns

  • (any) β€” The removed value

Example


arrayShift

Removes and returns the first element of an array.

Parameters

  • inputArray (table) β€” The array to modify

Returns

  • (any) β€” The removed value

Example


arrayPush

Adds one or more elements to the end of an array.

Parameters

  • inputArray (table) β€” The array to modify

  • ... (any) β€” Values to add

Returns

  • (number) β€” New array length

Example


arrayUnshift

Inserts one or more elements at the start of an array.

Parameters

  • inputArray (table) β€” The array to modify

  • ... (any) β€” Values to insert

Returns

  • (number) β€” New array length

Example


arraySlice

Creates a shallow copy of a portion of an array.

Parameters

  • sourceArray (table) β€” The array to slice

  • fromIndex (number) β€” Starting index

  • toIndex (number) β€” Ending index

Returns

  • (table) β€” New array slice

Example


arrayReduce

Reduces an array to a single value.

Parameters

  • sourceArray (table) β€” The array to reduce

  • reducer (function) β€” Function (accumulator, value, index)

  • initial (any) β€” Initial accumulator value

Returns

  • (any) β€” Reduced result

Example


arrayReverse

Reverses the array in place.

Parameters

  • inputArray (table) β€” The array to reverse

Returns

  • (table) β€” The same array, reversed

Example


arrayToReversed

Creates a new reversed array without modifying the original.

Parameters

  • sourceArray (table) β€” The array to reverse

Returns

  • (table) β€” New reversed array

Example


isArray

Determines whether a table is array-like (1..n without gaps).

Parameters

  • inputTable (table) β€” Table to check

Returns

  • (boolean) β€” Whether the table is an array

Example


arrayRandom

Returns a random element from an array.

Parameters

  • sourceArray (table) β€” The array to pick from

Returns

  • (any | nil) β€” Random element or nil

Example


arrayShuffle

Randomly shuffles an array in place.

Parameters

  • sourceArray (table) β€” The array to shuffle

Returns

  • (table) β€” Shuffled array

Example


arrayUnique

Removes duplicate values from an array.

Parameters

  • sourceArray (table) β€” The array to process

Returns

  • (table) β€” Array with unique values

Example

Last updated