L
Leon Hurley
Guest
[Currently using GM 1.4]
I have a simple saving system that uses 0s and 1s to record if the player interacts with objects (opens a door, picks something up etc). To avoid coding each save individually I pass arguments from a save object in each room to a script, defining the save file name, the ds_list name, the room the player's in, and the number of values needing to be saved:
I worked perfectly when all the code was in its respective objects, but using scripts is obviously doing something I don't understand.
What am I getting wrong?
Thanks
I have a simple saving system that uses 0s and 1s to record if the player interacts with objects (opens a door, picks something up etc). To avoid coding each save individually I pass arguments from a save object in each room to a script, defining the save file name, the ds_list name, the room the player's in, and the number of values needing to be saved:
A script then takes all that and creates, save or loads the values as needed:current_save_file = "save_data" + string(global.current_save) + ".ini"
ds_list_name = "r1_save_data"
current_room = "r1"
list_size = 3
scr_basic_save(current_save_file, ds_list_name, current_room, current_room, list_size);
This works perfectly when moving between a room and the pause menu (another room without a save object currently) but seems to reset when I move between two gameplay rooms where there are different save objects.//Arguments
save_file = argument0
save_ds_list_name = argument1
save_key = argument2
save_rm = argument3
save_ds_list_size = argument4
//save the current room
ini_open(save_file)
ini_write_real("Main data", "room", save_rm);
ini_close();
//Create the list
save_ds_list_name = ds_list_create();
//Set all the save values to zero or load them
ini_open(save_file)
if !ini_key_exists(save_file, save_rm)
{
for (i=0;i<save_ds_list_size;i+=1)
{
ds_list_add(save_ds_list_name, 0);
save = ds_list_write(save_ds_list_name)
ini_open(save_file)
ini_write_string(string("savedata"), save_rm, save);
ini_close();
}
}
else if ini_key_exists(save_file, save_rm)
{
load = ini_read_string(string("savedata"), save_rm, "")
ds_list_read(save_ds_list_name, load);
}
ini_close();
return save_ds_list_name;
I worked perfectly when all the code was in its respective objects, but using scripts is obviously doing something I don't understand.
What am I getting wrong?
Thanks
Last edited by a moderator: