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.
array_first(array);
Argument | Type | Description |
---|---|---|
array | Array | The array to get the first value from |
Any (Any valid data type that an array can hold)
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.