array_first

This function returns the element at the start of the array, i.e. the first element at index 0.

NOTE Use array_shift to also remove the first element from the array.

 

Syntax:

array_first(array);

ArgumentTypeDescription
arrayArrayThe array to get the first value from

 

Returns:

Any (Any valid data type that an array can hold)

 

Example:

var _first_added_enemy = array_first(enemies);

with (_first_added_enemy)
{
    show_debug_message(string(id) + " is the first enemy in the array.");
}

The above code gets the first enemy instance added to the array enemies and stores it in a temporary variable _first_added_enemy. It then lets the instance display a debug message with the id of the instance.