ds_grid_get_sum

This function can be used to add all the values all the cells found within the defined region of a grid together, as shown in the image below:

DS grid get sum

 

Syntax:

ds_grid_get_sum(index, x1, y1, x2, y2);

ArgumentTypeDescription
indexDS GridThe index of the grid.
x1RealThe left cell column of the region.
y1RealThe top cell row of the region.
x2RealThe right cell column of the region.
y2RealThe bottom cell row of the region.

 

Returns:

Real or String

 

Example:

val = ds_grid_get_sum(grid, 0, 0, 5, 5)

The above code will set the variable "val" to the sum of all values contained within the given region of the DS grid indexed in the variable "grid".