Divinik
Member
So in the game I'm currently working on, every companion and their info is stored in a ds_grid (Companions_Grid), and within each companion's column is another inventory grid stored for the companion.
The code for storing the inventory grids into the json seems to be working perfectly, I check the json files each time I run the game and all grids are there with their unique identifiers.
Here is the code for writing the inventory grid data into the ds_map for the json file:
(The ds_list named com_invData is used to find all companion inventories and read them into a ds_map. Companions_Grid[# 7, i] is the grid_position of the companion inventory.)
When the load_instances() script is called, this section handles loading the companion inventories:
So if I execute the loading script while in the game or when I first start the game, it works without a hitch. But if I restart the game, the first companion on the grid's inventory will look like this:
Anyone have any idea why this is happening? Any help would be appreciated!
The code for storing the inventory grids into the json seems to be working perfectly, I check the json files each time I run the game and all grids are there with their unique identifiers.
Here is the code for writing the inventory grid data into the ds_map for the json file:
(The ds_list named com_invData is used to find all companion inventories and read them into a ds_map. Companions_Grid[# 7, i] is the grid_position of the companion inventory.)
Code:
///In the save_instances() script
ds_list_clear(com_invData);
for (var i = 0; i < ds_grid_height(Companions_Grid); i++)
{
ds_list_add(com_invData, ds_grid_write(Companions_Grid[# 7, i]));
var my_key = "com_inv"+string_hash_to_newline(i)+string_hash_to_newline(Companions_Grid[# 0, i]);
ds_map_add(wrapper_map, my_key, ds_list_find_value(com_invData, i));
}
When the load_instances() script is called, this section handles loading the companion inventories:
Code:
for (var i = 0; i < ds_grid_height(Companions_Grid); i++)
{
var my_key = "com_inv"+string_hash_to_newline(i)+string_hash_to_newline(Companions_Grid[# 0, i]);
ds_string = wrapped_map[?my_key];
if ds_string != undefined
{
var inv_toChange = Companions_Grid[# 7, i];
ds_grid_clear(inv_toChange, undefined);
ds_grid_resize(inv_toChange, 0, 0);
ds_grid_read(inv_toChange, ds_string);
}
}
Anyone have any idea why this is happening? Any help would be appreciated!
Last edited: