• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Accessing array

Bentley

Member
I have a dumb question, but, oh well, I'll look silly. Lets say I create a ds_grid and set every position to be a pointer for an array:
Code:
global.grid = ds_grid_create(COLS, ROWS);

for (var xx = 0; xx < COLS; xx++)
{
    for (var yy = 0; yy < ROWS; yy++)
    {
        global.grid[# xx, yy] = [EAST, WEST, SOUTH, NORTH];
    }
}
I know I can access the pointer for the array and the values for that array like so:
Code:
var a = global.grid[# 0, 0]; // Store the pointer for the array at grid position 0,0
show_message(a[0]); // EAST
show_message(a[1]); // WEST
show_message(a[2]); // SOUTH
show_message(a[3]); // NORTH
Is there a way to use the pointer directly from the grid? These obviously don't work, but this is what I had in mind.
Code:
show_message(global.grid[# 0, 0].[0]);
show_message(global.grid[# 0, 0][0]);
 
Last edited:
Top