Advertisement
Dekita

save 1.1

Feb 8th, 2013
939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.48 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.1
  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. o8/o2/2o13 - update to save after X steps,
  41. 23/o1/2o13 - started && finished,
  42.  
  43. ================================================================================
  44. Credit and Thanks to :
  45. =======================
  46.  
  47. ================================================================================
  48. Known Bugs:
  49. ============
  50. N/A
  51.  
  52. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53. If a new bug is found please contact me at
  54. http://dekitarpg.wordpress.com/
  55.  
  56. ================================================================================
  57. INSTRUCTIONS:
  58. ==============
  59. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  60.  
  61. ================================================================================
  62. Script Calls :
  63. ===============
  64. $game_system.save_after_transfer = bool
  65. $game_system.save_after_battle = bool
  66. $game_system.save_after_menu = bool
  67. $game_system.save_file_index = save file index
  68.  
  69. replace bool with true / false
  70. only use the last script call if you REALLY need to change the save file index.
  71.  
  72. =end #=========================================================================#
  73.  
  74. module Awesome_Autosave
  75.  
  76. Save_After_Transfer = true
  77.  
  78. Save_After_Battle = false#true
  79.  
  80. Save_After_Menu = false#true
  81.  
  82. Save_After_Steps = [false, 50] # use ? steps before save
  83.  
  84. Save_File_Limit = 50 # Default = 16
  85.  
  86. end #####################
  87. # CUSTOMISATION END #
  88. #################################################################################
  89. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  90. # #
  91. # http://dekitarpg.wordpress.com/ #
  92. # #
  93. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  94. #===============================================================================#
  95. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  96. # YES?\.\. #
  97. # OMG, REALLY? \| #
  98. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  99. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  100. #################################################################################
  101.  
  102. $imported = {} if $imported.nil?
  103. $imported[:Dekita_Autosave] = true
  104.  
  105. #===============================================================================#
  106. module DataManager
  107. #===============================================================================#
  108.  
  109. class << self
  110. alias :sng_as_DM :setup_new_game
  111. alias :lg_as_DM :load_game
  112. alias :sg_as_DM :save_game
  113. end
  114.  
  115. def self.save_game(index)
  116. $game_system.save_file_index = index
  117. sg_as_DM(index)
  118. end
  119.  
  120. def self.load_game(index)
  121. $game_system.save_file_index = index
  122. lg_as_DM(index)
  123. end
  124.  
  125. def self.save_file_count
  126. cont = Dir.glob('Save*.rvdata2').size
  127. cont
  128. end
  129.  
  130. def self.savefile_max
  131. Awesome_Autosave::Save_File_Limit
  132. end
  133.  
  134. end
  135.  
  136. #==============================================================================
  137. class Game_System
  138. #==============================================================================
  139.  
  140. include Awesome_Autosave
  141.  
  142. attr_accessor :save_file_index
  143. attr_accessor :save_after_transfer
  144. attr_accessor :save_after_battle
  145. attr_accessor :save_after_menu
  146. attr_reader :just_battled_flag
  147.  
  148. alias :_GS_init_Autosave :initialize
  149. def initialize
  150. _GS_init_Autosave
  151. @save_file_index = 0
  152. @save_after_transfer = Save_After_Transfer
  153. @save_after_battle = Save_After_Battle
  154. @save_after_menu = Save_After_Menu
  155. @just_battled_flag = false
  156. end
  157.  
  158. def just_battled
  159. @just_battled_flag = true
  160. end
  161.  
  162. def saved_after_battle_AS
  163. @just_battled_flag = false
  164. end
  165.  
  166. end
  167.  
  168. #==============================================================================
  169. class Game_Party < Game_Unit
  170. #==============================================================================
  171.  
  172. def on_battle_end
  173. $game_system.just_battled
  174. super
  175. end
  176.  
  177. end
  178.  
  179. #==============================================================================
  180. class Game_Player < Game_Character
  181. #==============================================================================
  182.  
  183. alias :inc_step_n_init :initialize
  184. alias :inc_step_n_save :increase_steps
  185.  
  186. attr_accessor :old_step_count
  187. attr_reader :steps_counter
  188.  
  189. def initialize
  190. inc_step_n_init
  191. @steps_counter = 0
  192. @old_step_count = 0
  193. end
  194.  
  195. def increase_steps
  196. inc_step_n_save
  197. @steps_counter += 1
  198. end
  199.  
  200. def reset_steps_counter
  201. @steps_counter = 0
  202. end
  203.  
  204. end
  205.  
  206. #==============================================================================
  207. class Scene_Base
  208. #==============================================================================
  209.  
  210. def auto_save
  211. index = $game_system.save_file_index
  212. DataManager.save_game(index)
  213. p "Saving on file " + index.to_s
  214. end
  215.  
  216. end
  217.  
  218. #==============================================================================
  219. class Scene_Map < Scene_Base
  220. #==============================================================================
  221.  
  222. alias :def_start_AS_GM :start
  223. alias :pt_as_dekita :post_transfer
  224.  
  225. def start
  226. def_start_AS_GM
  227. start_autosave
  228. end
  229.  
  230. def perform_transition
  231. if Graphics.brightness == 0
  232. Graphics.transition(0)
  233. fadein(fadein_speed)
  234. else
  235. super
  236. end
  237. end
  238.  
  239. def post_transfer
  240. pt_as_dekita
  241. auto_save if $game_system.save_after_transfer
  242. end
  243.  
  244. def start_autosave
  245. return unless $game_system.save_after_battle
  246. return unless $game_system.just_battled_flag
  247. $game_system.saved_after_battle_AS
  248. auto_save
  249. end
  250.  
  251. alias :updt_steps_save :update
  252. def update
  253. updt_steps_save
  254. if Awesome_Autosave::Save_After_Steps[0]
  255. if $game_player.steps_counter >= Awesome_Autosave::Save_After_Steps[1]
  256. $game_player.reset_steps_counter
  257. auto_save
  258. end
  259. end
  260. end
  261.  
  262. end
  263.  
  264. #==============================================================================
  265. class Scene_Menu < Scene_MenuBase
  266. #==============================================================================
  267.  
  268. def return_scene
  269. auto_save if $game_system.save_after_menu
  270. super
  271. end
  272.  
  273. end
  274.  
  275. #==============================================================================
  276. class Scene_Title < Scene_Base
  277. #==============================================================================
  278.  
  279. alias :cng_AS_ST :command_new_game
  280.  
  281. def command_new_game
  282. cng_AS_ST
  283. $game_system.save_file_index = DataManager.save_file_count
  284. end
  285.  
  286. end
  287.  
  288. #===============================================================================#
  289. # - SCRIPT END - #
  290. #===============================================================================#
  291. # http://dekitarpg.wordpress.com/ #
  292. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement