I'm just getting into understanding how to save and load my game and have had success with saving and loading single variables using the ds_map system, however I'm having many issues with doing the same with arrays.
I've tried using ds_lists and searched around the internet for anyone else asking the same thing.
From that I've gotten some parts of the code done but I'm not sure if the syntax is right or I'm missing something completely.
I'm trying to save an array that holds all the values for the players stats and attributes.
obj_manager create:
obj_manager user_event(0): //Saving
obj_manager user_event(1): //Loading
I've tried using ds_lists and searched around the internet for anyone else asking the same thing.
From that I've gotten some parts of the code done but I'm not sure if the syntax is right or I'm missing something completely.
I'm trying to save an array that holds all the values for the players stats and attributes.
obj_manager create:
Code:
//Save file
save_data = ds_map_create();
file_name = "SaveData.sav";
Code:
//Save checkpoint
ds_map_replace(save_data,"current_area",current_area);
ds_map_replace(save_data,"checkpointx",global.checkpointx);
ds_map_replace(save_data,"checkpointy",global.checkpointy);
//Save stats
var list_stats = ds_list_create();
for (i = 0; i < 6; i++)
ds_list_add(list_stats,obj_menu_smithing.stats[i]) //obj_menu_smithing holds the array
ds_map_add_list(save_data,"list_stats",list_stats)
ds_map_secure_save(save_data,file_name);
Code:
if !file_exists(file_name)
exit;
ds_map_destroy(save_data);
save_data = ds_map_secure_load(file_name);
//Load checkpoint
current_area = ds_map_find_value(save_data,"current_area");
global.checkpointx = ds_map_find_value(save_data,"checkpointx");
global.checkpointy = ds_map_find_value(save_data,"checkpointy");
//Load stats
obj_menu_smithing.stats = ds_map_find_value(save_data,"list_stats");