ds_grid_value_y

With this function you can get the y coordinate (within the given rectangular grid region) of the value being searched for. You give the DS grid index (as returned by ds_grid_create()) along with the x/y positions for the top left and bottom right corners of the grid region to search, before supplying the value to search for. If the value being searched for does not exist, then the function will return -1.

 

Syntax:

ds_grid_value_y(index, x1, y1, x2, y2, val);

ArgumentType Description
indexDS Grid The index of the grid.
x1Real The x position of the left of the region in the grid, from 0 to (grid width - 1).
y1Real The y position of the top of the region in the grid, from 0 to (grid height - 1).
x2Real The x position of the right of the region in the grid, from 0 to (grid width - 1).
y2Real The y position of the bottom of the region in the grid, from 0 to (grid height - 1)
valAny The value to find.

 

Returns:

Real

 

Example:

if ds_grid_value_exists(grid, 0, 1, 5, 6, val)
{
    xpos = ds_grid_value_x(grid, 0, 1, 5, 6, val);
    ypos = ds_grid_value_y(grid, 0, 1, 5, 6, val);
}

The above code checks a ds_grid for a specific value within a rectangular region. if it is found, it then stores the x and y position of the value in two variables for later use.