• 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!

Legacy GM Problem with ds_grid_width & height

A

AlexZ

Guest
Hi, I googled and couldnt find anything that'd help me and I really dont know what I'm doing wrong so I made an account here. hope u guys can help me.

I got the following thing:

grid_board = ds_grid_create (10, 10);
var i, i2;
for (i = 0; i < ds_grid_width(grid_board) ; i ++)
{
for (i2 = 0; i2 < ds_grid_height(grid_board); i2 ++)
{

// stuff happens here

};
};

Then I get the following error:
ds_grid_height argument 1 incorrect type (array) expecting a Number (YYGI32)
at gml_Script_scr_setupboard (line x) - for (i2 = 0; i2 < ds_grid_height(grid_board); i2 ++)

idk whats going on, shouldnt ds_grid_height(...) return a number? why does the error message say this is an array? I get the same error when I try to compare ds_grid_width in an if-statement like
"if (i < ds_grid_width(grid_board) - 1) {
//something
};
What am I doing wrong? :(

thanks in advance for ur help.
 
A

AlexZ

Guest
thats a thing i got used to. it doesnt really change the code.
of course removing the ; didnt fix it but thanks for your answer.
 
Are you accessing grid_board anywhere in your code using square brackets? If you are doing this grid_board[0,0] , it will convert it into an array type.

Make sure you are using the grid accessor (#):

grid_board[# 0, 0]
 
Top