Advertisement
AngryPacman

[VXA] Backup Module

Feb 19th, 2012
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.02 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Backup Module (1.0)
  4. # 19/02/2012
  5. # By Pacman (inspired by Woratana)
  6. # -----------------------------------------------------------------------------
  7. # This script will backup your data files (i.e., files in the Data folder
  8. # of your game directory) and store them in a new folder. You may designate
  9. # if the backup occurs at the very start of any testing session and what
  10. # directory it saves to.
  11. # You may also backup manually in-game (if you want to do that for some reason)
  12. # with the script call:
  13. # backup(dir)
  14. # Where dir is the directory (in quotation marks) specified to put the backup.
  15. # Dir defaults to the directory set in the configuration, so you don't need
  16. # to include it.
  17. # I advise you don't use this command in the final release of your game,
  18. # especially if you plan on encrypting it. This script is for testing purposes
  19. # only. Setup below.
  20. #
  21. # -----------------------------------------------------------------------------
  22.  
  23. module BACKUP             # Do not touch this line.
  24.   BACKUP_WHEN_TEST = true # Backup on test session?
  25.   DIRNAME = 'Backup Data' # Directory backup will be saved to (will be created).
  26.  
  27. # -----------------------------------------------------------------------------
  28. #
  29. #   DO NOT EDIT PAST HERE
  30. #
  31. #===============================================================================
  32.  
  33. SCRIPT = <<_SCRIPT_
  34.     if (BACKUP_WHEN_TEST && #{'$TEST'}) || !BACKUP_WHEN_TEST
  35.       Dir.mkdir(DIRNAME) unless File.directory?(DIRNAME)
  36.       ftype = "#{'rvdata2'}"
  37.       flist = Dir.glob('./Data/*.{' + ftype + '}')
  38.       flist.each_index do |i|
  39.         flist[i] = flist[i].split('/').last
  40.         save_data(load_data('Data/' + flist[i]), DIRNAME + '/' + flist[i])
  41.       end
  42.     end
  43. _SCRIPT_
  44.  
  45. eval(SCRIPT) unless $@
  46. end
  47.  
  48. #==============================================================================
  49. # ■ Game_Interpreter
  50. #------------------------------------------------------------------------------
  51. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  52. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  53. #==============================================================================
  54.  
  55. class Game_Interpeter
  56.   #--------------------------------------------------------------------------
  57.   # * Manual Backup
  58.   #--------------------------------------------------------------------------
  59.   def backup(dir = BACKUP::DIRNAME)
  60.     Dir.mkdir(dir) unless File.directory?(dir)
  61.     ftype = "#{'rvdata2'}"
  62.     flist = Dir.glob('./Data/*.{' + ftype + '}')
  63.     flist.each_index do |i|
  64.       flist[i] = flist[i].split('/').last
  65.       save_data(load_data('Data/' + flist[i]), dir + '/' + flist[i])
  66.     end
  67.   end
  68. end
  69.  
  70. $imported ||= {}
  71. $imported[:pac_backup]
  72.  
  73. #===============================================================================
  74. #
  75. # END OF SCRIPT
  76. #
  77. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement