adiktuzmiko

Quick Save/Load System 1.01 - Khas Fix

May 27th, 2016
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.90 KB | None | 0 0
  1. =begin
  2. ====================================================================
  3.   GENERAL INFORMATION
  4. --------------------------------------------------------------------
  5.   Title: Quick Save/Load System
  6.   Author: Adiktuzmiko
  7.   Version: 1.01 - Khas' Fix
  8.   Requirements: None
  9.  
  10.   This script allows you to set a button in the game for quick save and load.
  11.   If you press the quicksave button, the game will automatically save
  12.   your progress in the designated slot without going thru the save screen.
  13.   The same goes for quickload.
  14.  
  15. ====================================================================
  16.  
  17. ====================================================================
  18.   FEATURES
  19. --------------------------------------------------------------------
  20.  
  21.   Quick Save/Load Anytime
  22.   - Save/Load your progress with the press of a button
  23.  
  24.   Customizable
  25.   - Modify which file index is used as the quick slot
  26.   - Modify which buttons
  27.   - Determine if quick system is usable in battle and during show text
  28.     event commands
  29.    
  30.   Works with Khas' Awesome Light Effects
  31.  
  32. ====================================================================
  33.  
  34. ====================================================================
  35.   INSTRUCTIONS
  36. --------------------------------------------------------------------
  37.  
  38.   After importing this script to your project, go to the config part
  39.   below (after TERMS AND CONDITIONS) and edit to suit your needs.
  40.  
  41. ====================================================================
  42.  
  43. ====================================================================
  44.   TERMS AND CONDITIONS
  45. --------------------------------------------------------------------
  46.  
  47.   View it here: http://lescripts.wordpress.com/terms-and-conditions/
  48.  
  49. ====================================================================
  50.  
  51. =end
  52.  
  53. module ADIK
  54.   module QUICK
  55.    
  56.     #Is the system enabled?
  57.     ENABLED = true
  58.    
  59.     #Save file index to be used by Quick save/load
  60.     #Note that by default the first file is index 0
  61.     INDEX = 0
  62.    
  63.     #SaveLoad Keybindings
  64.     #Default are L and R keys (Q/W at the keyboard by default)
  65.     SAVE_KEY = :L
  66.     LOAD_KEY = :L
  67.    
  68.     #Set these if you want to use a button "combo" to activate the system
  69.     #Example if SAVE_KEY is set as :L and SAVE_KEY_2 is set as :A
  70.     #then you need to press both to activate the quick save
  71.     SAVE_KEY_2 = nil
  72.     LOAD_KEY_2 = :A
  73.    
  74.     #Is the system allowed in battle scene?
  75.     #I suggest keeping this as false
  76.     ALLOW_AT_BATTLE = false
  77.    
  78.     #Is the system allowed during the Show Text event command?
  79.     ALLOW_AT_TEXT = true
  80.    
  81.   end
  82. end
  83.  
  84. # DO NOT EDIT BELOW THIS LINE
  85.  
  86. if ADIK::QUICK::ENABLED
  87.  
  88.   class Scene_Quick < Scene_File
  89.    
  90.     attr_accessor :quick_save
  91.     attr_accessor :quick_load
  92.    
  93.     def create_help_window
  94.     end
  95.     def help_window_text
  96.     end
  97.     def create_savefile_viewport
  98.       @savefile_viewport = Viewport.new
  99.       @savefile_viewport.rect.y = 0
  100.       @savefile_viewport.rect.height = 0
  101.     end
  102.     def create_savefile_windows
  103.       @savefile_windows = Array.new(item_max) do |i|
  104.         Window_SaveFile.new(savefile_height, i)
  105.       end
  106.       @savefile_windows.each {|window| window.viewport = @savefile_viewport; window.hide }
  107.     end
  108.     def init_selection
  109.     end
  110.    
  111.     def update
  112.       if @quick_save
  113.         if DataManager.save_game(ADIK::QUICK::INDEX)
  114.           Sound.play_save
  115.         else
  116.           Sound.play_buzzer
  117.         end
  118.         @quick_save = false
  119.         SceneManager.return
  120.       end
  121.       if @quick_load
  122.         if DataManager.load_game(ADIK::QUICK::INDEX)
  123.           Sound.play_load
  124.           $game_system.on_after_load
  125.           @quick_load = false
  126.           SceneManager.goto(Scene_Map)
  127.         else
  128.           Sound.play_buzzer
  129.           @quick_load = false
  130.           SceneManager.return
  131.         end
  132.       end
  133.     end
  134.    
  135.     def quicksave
  136.       @quick_save = true
  137.     end
  138.    
  139.     def quickload
  140.       @quick_load = true
  141.     end
  142.    
  143.   end
  144.  
  145.   class Scene_Base
  146.    
  147.     def quicksave
  148.       SceneManager.call(Scene_Quick)
  149.       SceneManager.scene.quicksave
  150.     end
  151.    
  152.     def quickload
  153.       SceneManager.call(Scene_Quick)
  154.       SceneManager.scene.quickload
  155.     end
  156.    
  157.     def is_quicksave
  158.       if ADIK::QUICK::SAVE_KEY_2 != nil
  159.         return (Input.trigger?(ADIK::QUICK::SAVE_KEY) and Input.press?(ADIK::QUICK::SAVE_KEY_2))
  160.       else
  161.         if ADIK::QUICK::LOAD_KEY_2 != nil
  162.           return false if Input.press?(ADIK::QUICK::LOAD_KEY_2)
  163.         end
  164.         return Input.trigger?(ADIK::QUICK::SAVE_KEY)
  165.       end
  166.     end
  167.    
  168.     def is_quickload
  169.       if ADIK::QUICK::LOAD_KEY_2 != nil
  170.         return (Input.trigger?(ADIK::QUICK::LOAD_KEY) and Input.press?(ADIK::QUICK::LOAD_KEY_2))
  171.       else
  172.         if ADIK::QUICK::SAVE_KEY_2 != nil
  173.           return false if Input.press?(ADIK::QUICK::SAVE_KEY_2)
  174.         end
  175.         return Input.trigger?(ADIK::QUICK::LOAD_KEY)
  176.       end
  177.     end
  178.  
  179.    
  180.     def quicksystem
  181.       if is_quicksave and not SceneManager.scene_is?(Scene_Save)
  182.         if SceneManager.scene_is?(Scene_Battle) then
  183.           if ADIK::QUICK::ALLOW_AT_BATTLE
  184.             quicksave
  185.           end
  186.         else
  187.           quicksave
  188.         end
  189.         return
  190.       end
  191.       if is_quickload and not SceneManager.scene_is?(Scene_Load)
  192.         if SceneManager.scene_is?(Scene_Battle) then
  193.           if ADIK::QUICK::ALLOW_AT_BATTLE
  194.             quickload
  195.           end
  196.         else
  197.           quickload
  198.         end
  199.         return
  200.       end
  201.     end
  202.    
  203.     alias update_quicksystem update
  204.     def update
  205.       update_quicksystem
  206.       quicksystem
  207.     end
  208.    
  209.   end
  210.  
  211.   class Game_Interpreter
  212.  
  213.     def wait_for_message
  214.       while $game_message.busy?
  215.         SceneManager.scene.quicksystem if ADIK::QUICK::ALLOW_AT_TEXT
  216.         Fiber.yield  
  217.       end
  218.     end
  219.      
  220.   end
  221.  
  222. end
Advertisement
Add Comment
Please, Sign In to add comment