Advertisement
Guest User

Untitled

a guest
Aug 17th, 2022
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Check to see if there is a Save File.
  2.    
  3.     var save_file_exists = false; // False unless a save file is loaded.
  4.    
  5.    
  6.     // Steam Cloud Saving Handling START
  7.    
  8.     var steam_cloud_loading_success = false; // False until tested below.
  9.  
  10.  
  11.     // Only run Cloud Save parameters if Cloud Saving is enabled.
  12.     if (steam_is_cloud_enabled_for_account() and steam_is_cloud_enabled_for_app() and steam_file_exists("ns_save24.save")) {
  13.         try {
  14.             global.backup_loaded = false;
  15.             show_debug_message("File Loading: Steam Cloud is Enabled and Save File exists.");
  16.             var load_string = steam_file_read("ns_save24.save");
  17.            
  18.             var load_data = json_parse(load_string);
  19.            
  20.             var steam_cloud_loading_success = true;
  21.            
  22.             var save_file_exists = true;
  23.         }
  24.        
  25.         catch(_exception1) {
  26.             global.backup_loaded = true;
  27.             show_debug_message("File Loading: Steam Cloud is Enabled and Save File (Backup) exists.");
  28.             show_debug_message("Save file is corrupted. Loading this Backup from the Steam Cloud instead.");
  29.             if (steam_file_exists("ns_save24_backup2.save")) {
  30.                 var load_string = steam_file_read("ns_save24_backup2.save");
  31.            
  32.                 var load_data = json_parse(load_string);
  33.                
  34.                 var steam_cloud_loading_success = true;
  35.                
  36.                 var save_file_exists = true;
  37.             }
  38.         }
  39.     }
  40.  
  41.  
  42.     // Steam Cloud Saving Handling END
  43.    
  44.    
  45.     if (!steam_cloud_loading_success) {
  46.         show_debug_message("Steam Cloud is NOT ENABLED. Loading Local Saves instead.");
  47.         if (file_exists("ns_save24.save")) {
  48.             // Test to see if the file will load correctly by encapsulating the code with "try"
  49.             try {
  50.                 global.backup_loaded = false;
  51.                 file_fast_crypt_ultra("ns_save24.save", "ns_save24.save", false, "93uBSDfjJSDBnF2U83");
  52.                 // Load the Save File Data.
  53.                 var load_buffer = buffer_load("ns_save24.save");
  54.                 var load_string = buffer_read(load_buffer, buffer_string);
  55.                 buffer_delete(load_buffer);
  56.        
  57.                 // De-stringify the JSON data.
  58.                 var load_data = json_parse(load_string);
  59.                
  60.                 var save_file_exists = true;
  61.             }          
  62.             // If the "try" fails (save file corrupted, game would crash), do this instead:
  63.             catch(_exception2) {
  64.                 global.backup_loaded = true;
  65.                 file_fast_crypt_ultra("ns_save24_backup2.save", "ns_save24_backup2.save", false, "93uBSDfjJSDBnF2U83");
  66.                 // Load the Save File Data.
  67.                 var load_buffer = buffer_load("ns_save24_backup2.save");
  68.                 var load_string = buffer_read(load_buffer, buffer_string);
  69.                 buffer_delete(load_buffer);
  70.        
  71.                 // De-stringify the JSON data.
  72.                 var load_data = json_parse(load_string);
  73.                
  74.                 var save_file_exists = true;
  75.             }
  76.         }
  77.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement