SOLVED ds_grid_height argument 1 incorrect type (undefined) expecting a Number (YYGI32)

UberhenriK

Member
Hello,

I've created an inventory ds_grid for my game and a script that must get ds_grid as an argument, but it gives me an error:

ds_grid_height argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_GlobalScript_AddItem (line 18) - for (i = 0; i < ds_grid_height(GridToAddTo); ++i) {

here's full script:
GML:
/// @function addItem
/// @description Add an item to a grid
/// @argument0 DSGrid Grid_To_Add
/// @argument1 String Item_Name
/// @argument2 Int Item_Amount
/// @argument3 String Item_Description
/// @argument4 Sprite Item_Sprite
/// @argument5 Script Item_Script

GridToAddTo = argument0;
NewItemName = argument1;
NewItemAmount = argument2;
NewItemDescriprion = argument3;
NewItemSprite = argument4;
NewItemScript = argument5;

// Вариант 1 — Предмет уже есть в инвентаре
for (i = 0; i < ds_grid_height(GridToAddTo); ++i) {
    if (ds_grid_get(GridToAddTo, 0, i) == NewItemName) {
        ds_grid_set(GridToAddTo, 1, i, ds_grid_get(GridToAddTo, 1, i) + NewItemAmount);
        return true;
    }
}


// Вариант 2 — Предмета ещё нет в инвентаре
if (ds_grid_get(GridToAddTo, 0, 0) != 0){
    ds_grid_resize(GridToAddTo, PlayerInventoryWidth, ds_grid_height(GridToAddTo) + 1);
}

NewItepSpot = ds_grid_height(GridToAddTo) - 1;
ds_grid_set(GridToAddTo, 0, NewItemSpot, NewItemName);
ds_grid_set(GridToAddTo, 1, NewItemSpot, NewItemAmount);
ds_grid_set(GridToAddTo, 2, NewItemSpot, NewItemDescriprion);
ds_grid_set(GridToAddTo, 3, NewItemSpot, NewItemSprite);
ds_grid_set(GridToAddTo, 4, NewItemSpot, NewItemScript);

return true;

How can i solve it?

P.S. I'm not an english speaking person so there may be some grammar mistakes : )
 

TsukaYuriko

☄️
Forum Staff
Moderator

UberhenriK

Member
Are you using 2.2 script syntax in 2.3?

Thank you! I've used 3 years old tutorial abd don't even knew about syntax change.
You helped me a lot!
 
Top