Advertisement
Sindn

No more manual structs!

Jun 22nd, 2023
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //obj_saveload create event
  2. global.levelData = {}; //Initialize empty struct, leave it completely blank!
  3.  
  4. //--------save_room function
  5. function save_room(){
  6.     var _room_struct = {
  7.     }
  8.    
  9.     //Save all of your things here normally, like in the video.
  10.  
  11.     //Store room NAME struct in global.levelData
  12.     global.levelData[$ room_get_name(room)] = _room_struct;
  13. }
  14.  
  15. function load_room(){
  16.     var _room_struct = 0;  
  17.    
  18.     //Simply get the levelData from the room's NAME we are in!
  19.     _room_struct = global.levelData[$ room_get_name(room)];
  20.        
  21.     //Just in case some weird stuff happens, exit!
  22.     if(is_undefined(_room_struct)){
  23.         exit;  
  24.     }
  25.    
  26.     if(!is_struct(_room_struct)){
  27.         exit;      
  28.     }
  29.  
  30.     //Load all your stuff here, like in the video
  31. }
  32. //The save game and load game functions stay the same. Now you won't have to worry about creating a new struct for every room!
  33. //Remember: Once you release your game, you cannot rename your rooms, or any assets really, as this will absolutely cause save file corruption and your players will be very angry!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement