The "array_height" Function

Syntax

array_height(id);
ArgumentTypeDescription
idarrayThe index of a previously-created array to check

Description

Returns the number of vertical cells present in a 1D or 2D array. If the 2D array has non-uniform height among different columns, the tallest column count will be returned.

important

Just because a 2D array has a certain height does not guarantee that data exists at the highest column index of every row. Attempting to access data in shorter columns will result in an error. To avoid this behavior, it is recommended to use array_fill_2d.

Vanilla GML array length and height functions reverse the X and Y values relative to data structures like ds_grid. This is confusing. By contrast, GML+ uses the same dimension for width and height as other data structures.

Example

var last_cell = array_height(my_array) - 1;