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

Ds_grid_get error

M

Matt Benner

Guest
I'm trying to draw a custom high scores table but any time the draw object runs I get the following error
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object obj_drawScores:

ds_grid_get argument 1 incorrect type (array) expecting a Number (YYGI32)
at gml_Object_obj_drawScores_Draw_0 (line 45) - draw_text(640,256 +(i*64), ds_grid_get(global.HighScoresArray, 0, i));
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawScores_Draw_0 (line 45)




Here is the code in question

for (var i = 0; i < 10; ++i)
{
draw_text(448,256 +(i*64), i + 1);
draw_text(640,256 +(i*64), ds_grid_get(global.HighScoresArray, 0, i));
draw_text(832,256 +(i*64), ds_grid_get(global.HighScoresArray, 1, i));
}

The array itself is created during game startup and populated before the player enters the high score room where the table is to be drawn. I'm sure i just messing this up somehow, can anyone see what the issue is?
 
Show the creation code for your grid / array.

This is an educated guess, if you really did create a ds_grid, you may have forgotten to use the grid accessor (#) when populating it.

E.G.

global.highScoresArray[0, 0] = 100

should be :

global.highScoresArray[# 0, 0] = 100
 
M

Matt Benner

Guest
Well

Why are you using ds_grid functions to try fetching data from an array
Sorry said array meant grid, very definitely a grid.


Show the creation code for your grid / array.

This is an educated guess, if you really did create a ds_grid, you may have forgotten to use the grid accessor (#) when populating it.

E.G.

global.highScoresArray[0, 0] = 100

should be :

global.highScoresArray[# 0, 0] = 100

whoops, yeah it was basically this, remembered it when creating the grid but not when I was pulling data from the .ini file.
thanks v much.
 

MudbuG

Member
Show the creation code for your grid / array.

This is an educated guess, if you really did create a ds_grid, you may have forgotten to use the grid accessor (#) when populating it.

E.G.

global.highScoresArray[0, 0] = 100

should be :

global.highScoresArray[# 0, 0] = 100
This just saved my bacon while working with a DS_MAP... one place in code, I had assigned a value to the map without using the "?" accessor. It would have taken me quite a while to find that one, probably... but thanks to this post, a little yellow light bulb went one. Much thanks!
 
Top