Advertisement
Dekita

Autosaave

Feb 7th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.0
  3. ★ Awesome Autosave™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script simply enables an autosave feature.
  9. Various options for when it saves. Also allows for more than 16 save files.
  10. If a new game is created it will automatically save into a new file.
  11. If you load a game it will save in the position of the file you loaded.
  12. If you save over a file at any time, the game will automatically save
  13. into that save file slot.
  14.  
  15. NOTE: I HIGHLY Reccommend you to disable all other methods of saving possible.
  16. This *WILL* prevent the potential overwrite of valuable data .
  17. But you dont have to..
  18.  
  19. ================================================================================
  20. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  21. ================================================================================
  22. 1. You must give credit to "Dekita"
  23. 2. You are NOT allowed to repost this script.(or modified versions)
  24. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  25. 4. You are NOT allowed to use this script for Commercial games.
  26. 5. ENJOY!
  27.  
  28. "FINE PRINT"
  29. By using this script you hereby agree to the above terms and conditions,
  30. if any violation of the above terms occurs "legal action" may be taken.
  31. Not understanding the above terms and conditions does NOT mean that
  32. they do not apply to you.
  33. If you wish to discuss the terms and conditions in further detail you can
  34. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  35.  
  36. ================================================================================
  37. History:
  38. =========
  39. D /M /Y
  40. 23/o1/2o13 - started && finished,
  41.  
  42. ================================================================================
  43. Credit and Thanks to :
  44. =======================
  45.  
  46. ================================================================================
  47. Known Bugs:
  48. ============
  49. N/A
  50.  
  51. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  52. If a new bug is found please contact me at
  53. http://dekitarpg.wordpress.com/
  54.  
  55. ================================================================================
  56. INSTRUCTIONS:
  57. ==============
  58. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  59.  
  60. ================================================================================
  61. Script Calls :
  62. ===============
  63. $game_system.save_after_transfer = bool
  64. $game_system.save_after_battle = bool
  65. $game_system.save_after_menu = bool
  66. $game_system.save_file_index = save file index
  67.  
  68. replace bool with true / false
  69. only use the last script call if you REALLY need to change the save file index.
  70.  
  71. =end #=========================================================================#
  72.  
  73. module Awesome_Autosave
  74.  
  75. Save_After_Transfer = true
  76.  
  77. Save_After_Battle = false#true
  78.  
  79. Save_After_Menu = false#true
  80.  
  81. Save_File_Limit = 50 # Default = 16
  82.  
  83. end #####################
  84. # CUSTOMISATION END #
  85. #################################################################################
  86. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  87. # #
  88. # http://dekitarpg.wordpress.com/ #
  89. # #
  90. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  91. #===============================================================================#
  92. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  93. # YES?\.\. #
  94. # OMG, REALLY? \| #
  95. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  96. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  97. #################################################################################
  98.  
  99. $imported = {} if $imported.nil?
  100. $imported[:Dekita_Autosave] = true
  101.  
  102. #===============================================================================#
  103. module DataManager
  104. #===============================================================================#
  105.  
  106. class << self
  107. alias :sng_as_DM :setup_new_game
  108. alias :lg_as_DM :load_game
  109. alias :sg_as_DM :save_game
  110. end
  111.  
  112. def self.save_game(index)
  113. $game_system.save_file_index = index
  114. sg_as_DM(index)
  115. end
  116.  
  117. def self.load_game(index)
  118. $game_system.save_file_index = index
  119. lg_as_DM(index)
  120. end
  121.  
  122. def self.save_file_count
  123. cont = Dir.glob('Save*.rvdata2').size
  124. cont
  125. end
  126.  
  127. def self.savefile_max
  128. Awesome_Autosave::Save_File_Limit
  129. end
  130.  
  131. end
  132.  
  133. #==============================================================================
  134. class Game_System
  135. #==============================================================================
  136.  
  137. include Awesome_Autosave
  138.  
  139. attr_accessor :save_file_index
  140. attr_accessor :save_after_transfer
  141. attr_accessor :save_after_battle
  142. attr_accessor :save_after_menu
  143. attr_reader :just_battled_flag
  144.  
  145. alias :_GS_init_Autosave :initialize
  146. def initialize
  147. _GS_init_Autosave
  148. @save_file_index = 0
  149. @save_after_transfer = Save_After_Transfer
  150. @save_after_battle = Save_After_Battle
  151. @save_after_menu = Save_After_Menu
  152. @just_battled_flag = false
  153. end
  154.  
  155. def just_battled
  156. @just_battled_flag = true
  157. end
  158.  
  159. def saved_after_battle_AS
  160. @just_battled_flag = false
  161. end
  162.  
  163. end
  164.  
  165. #==============================================================================
  166. class Game_Party < Game_Unit
  167. #==============================================================================
  168.  
  169. def on_battle_end
  170. $game_system.just_battled
  171. super
  172. end
  173.  
  174. end
  175.  
  176. #==============================================================================
  177. class Scene_Base
  178. #==============================================================================
  179.  
  180. def auto_save
  181. index = $game_system.save_file_index
  182. DataManager.save_game(index)
  183. p "Saving on file " + index.to_s
  184. end
  185.  
  186. end
  187.  
  188. #==============================================================================
  189. class Scene_Map < Scene_Base
  190. #==============================================================================
  191.  
  192. alias :def_start_AS_GM :start
  193. alias :pt_as_dekita :post_transfer
  194.  
  195. def start
  196. def_start_AS_GM
  197. start_autosave
  198. end
  199.  
  200. def perform_transition
  201. if Graphics.brightness == 0
  202. Graphics.transition(0)
  203. fadein(fadein_speed)
  204. else
  205. super
  206. end
  207. end
  208.  
  209. def post_transfer
  210. pt_as_dekita
  211. auto_save if $game_system.save_after_transfer
  212. end
  213.  
  214. def start_autosave
  215. return unless $game_system.save_after_battle
  216. return unless $game_system.just_battled_flag
  217. $game_system.saved_after_battle_AS
  218. auto_save
  219. end
  220.  
  221. end
  222.  
  223. #==============================================================================
  224. class Scene_Menu < Scene_MenuBase
  225. #==============================================================================
  226.  
  227. def return_scene
  228. auto_save if $game_system.save_after_menu
  229. super
  230. end
  231.  
  232. end
  233.  
  234. #==============================================================================
  235. class Scene_Title < Scene_Base
  236. #==============================================================================
  237.  
  238. alias :cng_AS_ST :command_new_game
  239.  
  240. def command_new_game
  241. cng_AS_ST
  242. $game_system.save_file_index = DataManager.save_file_count
  243. end
  244.  
  245. end
  246.  
  247. #===============================================================================#
  248. # - SCRIPT END - #
  249. #===============================================================================#
  250. # http://dekitarpg.wordpress.com/ #
  251. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement