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

GML ds_grid_get argument 1 incorrect type (array) expecting a Number (YYGI32)

S

shadow7692

Guest
I have a couple of data structures set up beforehand:
Code:
global.ItemIndex = ds_grid_create(Items.Length, Attributes.Length); // I have enums for these too.
Inventory = ds_list_create(); // [Items.ItemName (since its an enum, int64), Amount (int64), Equipped (boolean)]
When I run the code I get an error that 'ds_grid_get argument 1 incorrect type (array) expecting a Number (YYGI32)' and I have checked the argument being sent by using typeof() which does indeed return a number - what is going on here?

Code:
for (var i = 0; i < ds_list_size(Inventory); i++) {

    var Item = ds_list_find_value(Inventory, i);
    show_debug_message(typeof(Item[0])); // Returns int64
   
    if (ds_grid_get(global.ItemIndex, Item[0], Attributes.Class) == Class.Weapon) { // -- ERROR is here.
        // Other code
    };  
   
};
EDIT: I have also tried the accessor of global.ItemIndex[# Item[0], Attributes.Class] which still returns the same error.
 

Nidoking

Member
I don't know what the actual problem is, but do you get the same thing if you store Item[0] into another var and pass that in?
 
S

shadow7692

Guest
I don't know what the actual problem is, but do you get the same thing if you store Item[0] into another var and pass that in?
I do. I also get the same error if there are no variables and I literally just put global.ItemIndex[# 0, 0] when it's clearly a Number.
 
H

Homunculus

Guest
Can you post the full error message when using global.ItemIndex[# 0, 0] ?
 
S

shadow7692

Guest
Can you post the full error message when using global.ItemIndex[# 0, 0] ?
Here it is:

Code:
FATAL ERROR in
action number 1
of  Step Event0
for object oCharacter:

ds_grid_get argument 1 incorrect type (array) expecting a Number (YYGI32)
 at gml_Script_fnLightAttack (line 8) -        show_debug_message(global.ItemIndex[# 0, 0]);
 
H

Homunculus

Guest
You probably forgot a "#" somewhere when assigning a value to global.ItemIndex, turning the variable into a 2d array. That's the error you get if something like this happens, tested with the following:

GML:
grid[1,2] = 1;
show_debug_message(grid[# 0, 0]);
 
S

shadow7692

Guest
You probably forgot a "#" somewhere when assigning a value to global.ItemIndex, turning the variable into a 2d array. That's the error you get if something like this happens, tested with the following:

GML:
grid[1,2] = 1;
show_debug_message(grid[# 0, 0]);
Thank you! Just me being stupid forgetting to check properly.
 
Top