Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Backup System

Backup System
by .:Fênix:.


Description

Makes a copy of your game's folders

Compability

RPG Maker XP and RPG Maker VX

Script

Code:
#===============================================================================

# * Backup System

#-------------------------------------------------------------------------------

#   - Version: 2.0

#   - Date   : 21 / 08 / 2011

#   - Author : .:Fênix:.

#   - MSN    : [email=bmotamer@hotmail.com]bmotamer@hotmail.com[/email]

#-------------------------------------------------------------------------------

#   - Description:

#     Makes a copy of your game's folders

#-------------------------------------------------------------------------------

#   - Compability:

#     RPG Maker XP and RPG Maker VX

#===============================================================================

 

module Backup_System

  # Activate the script? (true / false)

  Activate = true

  # Copy Audio folder? (true / false)

  Audio = false

  # Copy Data folder? (true / false)

  Data = true

  # Copy Graphics folder? (true / false)

  Graphics = false

  # Seconds to make a new copy (if you set this 0, it will make

  # a copy every time you run the game)

  Time = 3600

end

 

if (Backup_System::Activate)

  

  $VX ||= defined?(Graphics.wait)

  

  if (File.file?("Game.rgss#{$VX ? '2a' : 'ad'}"))

    Thread.new {system("rd Backup /s /q")} if (File.directory?("Backup"))

    File.delete("Backup.time") if (File.file?("Backup.time"))

  else

    if (($DEBUG) || ($TEST))

      time = Time.now

      if ((!File.file?("Backup.time")) || ((time - load_data("Backup.time")) >= Backup_System::Time))

        baseDir = ""

        for subDir in ["Backup/", "#{time.year}-#{time.month}-#{time.day}/", "#{time.hour}.#{time.min}.#{time.sec}/"]

          baseDir += subDir

          Dir.mkdir(baseDir) unless (File.directory?(baseDir))

        end

        for subDir in ["Audio", "Data", "Graphics"]

          next unless (eval("Backup_System::#{subDir}"))

          dir = baseDir + subDir

          Dir.mkdir(dir) unless (File.directory?(dir))

          Thread.new {system("xcopy #{subDir}" + ' "' + dir.gsub!("/", "\\") + '" /e /c /q /r /y')}

        end

        save_data(time, "Backup.time")

      end

    end

  end

  

end
 
This is truely amazing, I have to agree with Juan. Not only do you not have to manually do it but this script allows you to automatically re-backup your files at the customized time. This will be really helpful for me, thanks :)
 
Only one slight problem. :3 While its a nice script and a nice idea and very very helpful, you'll most likely get a Script is Hanging error for the fact that Graphics.update needs to be called and if it doesn't get called within 10 seconds, it'll hang and close. So just add a Graphics.update in your for loops and it should be ok. Again nice script, not trying to dis your script or anything. xD
 
Actually it doesn't need Graphics.update, because I'm using Thread. I've tested this script with a 40mb project, and there was no lag to initialize the game. :D
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top