Returns the y position of a value within a region of a grid.


GML Code Example

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

Argument Description
index The index of the grid.
x1 The x position of the left of the region in the grid.
y1 The y position of the top of the region in the grid.
x2 The x position of the right of the region in the grid.
y2 The y position of the bottom of the region in the grid.
val The value to find.

Returns: Real


With this function you can get the x coordinate (within the given rectangular grid region) of the value being searched for. Be aware that if the value being searched for does not exists, the function will return 0, so it is a good idea to check if the values exists first with ds_grid_value_exists then run this function (along with the ds_grid_value_x function) to get the exact position within region being searched.


GML Code 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.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here