Devlog 0.9: Ren'Py Project Backups


Devlog 0.9: Ren'Py Project Backups

Backstory:

So recently, When I was making Start Chapter 5, atom NULL'ed my files, meaning OOF. So I decided to create a backup system that wouldn't place the backup files in the build.


Code:

Backup Exclusion

So basically, you want to go into options.rpy, and go to the archiving section. Once there, paste the first section of the code on the bottom of this post. Change the directory to wherever you are placing your backup files. You can remove any of the file types that you aren't using in your project. This piece of code is to exclude the backups in the build distributions.

Python

Next, we are going to make a file in the "game" folder, name it whatever you want. In there, paste in the 2nd section of the code. What this does is gets a list of files in the game directory, and excludes the subdirectories and the desktop.ini file. Once it has said list, it will create another file in a text format in the backup directory. If you are using a Mac, remove the desktop.ini exclusion. (I use shitk as a variable cause I dont like using x). Remove any of these that you aren't using in your project, as it will literally take the entire folder or make a new folder in the backup area.

Screen Implementation

Finally, we will implement said Python Code into a screen. It doesn't matter what screen you put it in, as long as you put it in a screen that is inaccessable to the player. Paste in the final piece of code. This is simply a text button that calls the backup_files() function we defined earlier in python blocks.


Congrats!

You just saved yourself alot of remaking in atom. :D

## Backup Exclusion ########################################################
    build.classify('game/admin/backups/**.rpy.txt', None)
    build.classify('game/admin/backups/**.sc.txt', None)
    build.classify('game/admin/backups/**.html.txt', None)
    build.classify('game/admin/backups/**.vbs.txt', None)
    build.classify('game/admin/backups/**.rpyc.txt', None)
    build.classify('game/admin/backups/**.txt.txt', None)
    build.classify('game/admin/backups/**.png.txt', None)
## Python ##################################################################
init python:
    
    import os
    def backup_files():
            game_shitk = os.listdir(config.basedir + "/game")
            game_shitk.remove("admin")
            game_shitk.remove("gui")
            game_shitk.remove("images")
            game_shitk.remove("saves")
            game_shitk.remove("cache")
            game_shitk.remove("sfx")
            game_shitk.remove("ext")
            game_shitk.remove("desktop.ini")
            for filenames in game_shitk:
                try:
                    renpy.file("../game/admin/backups/" + filenames + ".txt")
                except:
                    open(config.basedir + "/game/admin/backups/" + filenames + ".txt", "wb").write(renpy.file(filenames).read())
## Screen Implementation ####################################################
textbutton "Run Backup" action Function(backup_files)

Leave a comment

Log in with itch.io to leave a comment.