ds_grid_get

This function can be used to get the value from any cell within the given DS grid. If you pass invalid grid coordinates to the function, then the value returned will be undefined and an error will be shown in the output window.

 

Syntax:

ds_grid_get(index, x, y);

ArgumentType Description
indexDS Grid The index of the grid.
xReal The x position of the cell you want to find the value of.
yReal The y position of the cell you want to find the value of.

 

Returns:

Any

 

Example:

var xx = irandom(ds_grid_width(grid) - 1);
var yy = irandom(ds_grid_height(grid) - 1);
val = ds_grid_get(grid, xx, yy)

The above code selects a random cell from the DS grid indexed in the variable "grid" and stores its value in the variable "val".