FlameRooster
Member
Hi, I have a save/load system and it works 100% perfect on the Windows export, but when I try it on HTML5, it will either lag hard or freeze entirely. I don't know what is causing this. Would it be better to use cookies for HTML5 instead? Or ini?
I have 3 save files, and when you go into the save room or load room, all 3 files get opened in order for them to be read and drawn data from them on the screen, and of course I close them when I am done using the files.
Draw Event
Left Pressed Event
I will be saving data structures, and it says in the documentation that I should be using text files to save and load.
Can somebody point me in the right direction at least?
I have 3 save files, and when you go into the save room or load room, all 3 files get opened in order for them to be read and drawn data from them on the screen, and of course I close them when I am done using the files.
Code:
///scr_save_game()
//Create the save data structure
var save_data = ds_map_create();
//Player
save_data[? "money"] = global.money;
save_data[? "day"] = global.day;
////////////////////////////////////////////
var save_string = json_encode(save_data);
ds_map_destroy(save_data);
save_string = base64_encode(save_string);
var file = file_text_open_write(working_directory + argument0);
file_text_write_string(file, save_string);
file_text_close(file);
Code:
///scr_load_game()
var file = file_text_open_read(working_directory + argument0);
var save_string = file_text_read_string(file);
file_text_close(file);
save_string = base64_decode(save_string);
var save_data = json_decode(save_string);
if (!is_undefined(ds_map_find_value(save_data, "day"))) {
global.day = save_data[? "day"];
}
if (!is_undefined(ds_map_find_value(save_data, "money"))) {
global.money = save_data[? "money"];
}
Code:
if (file_exists(file)) {
draw_text(x-50, y-425, "Day: " + string(save_data[? "day"]));
draw_text(x-50, y-375, "Money: $" + string(save_data[? "money"]));
}
Code:
scr_save_game(file);
if (file_exists("Save1.txt") and fileNumber == 1) {
if (global.file1Open == true) {
file_text_close(fileOpen);
}
fileOpen = file_text_open_read(working_directory + "Save1.txt");
save_string = file_text_read_string(fileOpen);
save_string = base64_decode(save_string);
save_data = json_decode(save_string);
global.file1Open = true;
}
I will be saving data structures, and it says in the documentation that I should be using text files to save and load.
Can somebody point me in the right direction at least?
Last edited: