• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED "I32 argument is array

Hello this is my first post on this website. I've been trying to make a functional saving system but when I try to destroy the "wrapper" this error shows up. Here is my code:
Code:
var root = ds_list_create();

with(obj_psvng) {
    var map = ds_map_create();
    
    ds_list_add(root,map);
    ds_list_mark_as_map(root,ds_list_size(root)-1);
    
    ds_map_add(map,"obj",object_get_name(object_index));
    ds_map_add(map,"x",x);
    ds_map_add(map,"y",y);
    ds_map_add(map,"image_index",image_index);
    ds_map_add(map,"depth",depth);
    
    ds_list_add(root,inv,invcnt);
    ds_list_mark_as_map(root,ds_list_size(root)-1);
    ds_list_mark_as_map(root,ds_list_size(root)-2);
    
}

var wrapper = ds_map_create();
ds_map_add_list(wrapper,"root", root);

var text = json_encode(wrapper);

Write("world.pot",text)

ds_map_destroy(wrapper)

show_debug_message("yo dude I got your data!")
the error that shows up is called "I32 argument is array" and I dont understand why this error would show up because the argument that I put in is clearly a map and not an array or maybe I'm understanding something incorrectly? Full error message:
Code:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Key Press Event for <Enter> Key
for object obj_svng:

I32 argument is array
 at gml_Script_Saving (line 28) - ds_map_destroy(wrapper)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_Saving (line 28)
called from - gml_Object_obj_svng_KeyPress_13 (line 1) - Saving();
Any help is appreciated.
 

Homunculus

Member
Never seen this error before, but it's possible that the problem with this line is not the "wrapper" being the wrong type, but one of the inner data structures, since destroying the main map should destroy those as well.

Is it possible that inv or invcnt are not ds_maps but arrays or something else instead?
 
Yes thank you, they are ds_grids. What should I do if I only want the wrapper to be gone? I dont want inv and invcnt to be destroyed as well as I still need them during the game.
 

Homunculus

Member
You have a bigger problem than that; ds_grids can’t be serialized to json. You could try adding the result of ds_grid_write as a string instead, and convert it back with ds_grid_read at load time.

Like this you don’t even need to care about your grids being destroyed, they won’t.
 
Last edited:
Trying to use ds_grid_write caused me more problems. I seriously dont understand why this error shows up but here it is:
Code:
ds_grid_write argument 1 incorrect type (array) expecting a Number (YYGI32)
 at gml_Script_WriteInventory (line 10) - var temp = ds_grid_write(inv);
if you're wondering how the inv grid was created here:
Code:
globalvar inv;
globalvar invcnt;
inv = ds_grid_create(9,9);
invcnt = ds_grid_create(9,9);
for(i=0; i < invxy; i++) {
    for(j=0;j < invxy; j++) {
        inv[i,j] = 0;
        invcnt[i,j] = 0;
    }
}
I always struggle the most when it comes to saving my data. Thanks for helping.
 

FrostyCat

Member
Grids and 2D arrays are not the same thing. You created inv and invcnt as grids, then changed them to arrays by setting them like arrays. Do the sensible thing and set them like grids.
Code:
inv[# i, j] = 0;
inv[# i, j] = 0;
But if you're going to use grids anyways, skip the loop and just take advantage of ds_grid_set_region():
Code:
ds_grid_set_region(inv, 0, 0, invxy-1, invxy-1, 0);
ds_grid_set_region(invcnt, 0, 0, invxy-1, invxy-1, 0);
 
Top