I've been having issues with creating a reliable save system for the current project I'm working on. I'm trying to save an array which holds all the players stats, like an rpg. I already have ds_lists set up but I've had this consistent problem:
Once I have the game, storing all the values into the list and load them, If I add an additions/changes to that list, it doesn't save it.
Example:
Lets say the player increases their health to 3, then saves and loads. The health is now 3 and everything works fine
However if the player increases their health to 4 or 5, then saves and loads. The health didn't save and it's still at 3.
Code in a create even that happens at the start of the game:
Code for when the player saves:
Code for when the player loads:
I must be missing an important part of the code, like I got to properly remove the old save to write the new one. I'm not sure so any help would be great.
Once I have the game, storing all the values into the list and load them, If I add an additions/changes to that list, it doesn't save it.
Example:
Lets say the player increases their health to 3, then saves and loads. The health is now 3 and everything works fine
However if the player increases their health to 4 or 5, then saves and loads. The health didn't save and it's still at 3.
Code in a create even that happens at the start of the game:
GML:
//Save file
save_data = ds_map_create();
file_name = "SaveData.sav";
GML:
//Player stats
var list_stats = ds_list_create();
for (i = 0; i < 6; i++)
ds_list_add(list_stats,obj_menu_smithing.stats[i])
ds_map_add_list(save_data,"list_stats",list_stats)
ds_map_secure_save(save_data,file_name);
GML:
if !file_exists(file_name)
exit;
ds_map_destroy(save_data);
save_data = ds_map_secure_load(file_name);
//Player stats
var list = ds_map_find_value(save_data,"list_stats");
for (i = 0; i < ds_list_size(list); i++)
obj_menu_smithing.stats[i] = list[| i];