Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check to see if there is a Save File.
- var save_file_exists = false; // False unless a save file is loaded.
- // Steam Cloud Saving Handling START
- var steam_cloud_loading_success = false; // False until tested below.
- // Only run Cloud Save parameters if Cloud Saving is enabled.
- if (steam_is_cloud_enabled_for_account() and steam_is_cloud_enabled_for_app() and steam_file_exists("ns_save24.save")) {
- try {
- global.backup_loaded = false;
- show_debug_message("File Loading: Steam Cloud is Enabled and Save File exists.");
- var load_string = steam_file_read("ns_save24.save");
- var load_data = json_parse(load_string);
- var steam_cloud_loading_success = true;
- var save_file_exists = true;
- }
- catch(_exception1) {
- global.backup_loaded = true;
- show_debug_message("File Loading: Steam Cloud is Enabled and Save File (Backup) exists.");
- show_debug_message("Save file is corrupted. Loading this Backup from the Steam Cloud instead.");
- if (steam_file_exists("ns_save24_backup2.save")) {
- var load_string = steam_file_read("ns_save24_backup2.save");
- var load_data = json_parse(load_string);
- var steam_cloud_loading_success = true;
- var save_file_exists = true;
- }
- }
- }
- // Steam Cloud Saving Handling END
- if (!steam_cloud_loading_success) {
- show_debug_message("Steam Cloud is NOT ENABLED. Loading Local Saves instead.");
- if (file_exists("ns_save24.save")) {
- // Test to see if the file will load correctly by encapsulating the code with "try"
- try {
- global.backup_loaded = false;
- file_fast_crypt_ultra("ns_save24.save", "ns_save24.save", false, "93uBSDfjJSDBnF2U83");
- // Load the Save File Data.
- var load_buffer = buffer_load("ns_save24.save");
- var load_string = buffer_read(load_buffer, buffer_string);
- buffer_delete(load_buffer);
- // De-stringify the JSON data.
- var load_data = json_parse(load_string);
- var save_file_exists = true;
- }
- // If the "try" fails (save file corrupted, game would crash), do this instead:
- catch(_exception2) {
- global.backup_loaded = true;
- file_fast_crypt_ultra("ns_save24_backup2.save", "ns_save24_backup2.save", false, "93uBSDfjJSDBnF2U83");
- // Load the Save File Data.
- var load_buffer = buffer_load("ns_save24_backup2.save");
- var load_string = buffer_read(load_buffer, buffer_string);
- buffer_delete(load_buffer);
- // De-stringify the JSON data.
- var load_data = json_parse(load_string);
- var save_file_exists = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement