This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


Unarchiving files from rpa

With this script you are able to unarchive files from your rpa (as to give them to players as bonus presents etc...)

Example

init python:
    def unarchive(original_filename, new_filename):
        # original_filename is the name the file has when stored in the archive, including any 
        # leading paths.

        # new_filename is the name the file will have when extracted, relative to the base directory.
        
        import os
        import os.path

        new_filename = config.basedir + "/" + new_filename
        dirname = os.path.dirname(new_filename)
        
        if not os.path.exists(dirname):
            os.makedirs(dirname)

        orig = renpy.file(original_filename)
        new = open(new_filename, "wb")

        from shutil import copyfileobj
        copyfileobj(orig, new)

        new.close()
        orig.close()
        
            
label start:
    # We have Track01.mp3 in archive and images/photo.png in archive too
    
    # This will unarchive Track01.mp3 from archive basedir/extracted path
    $ unarchive("Track01.mp3", "extracted/Track01.mp3")
    
    # This will unarchive photo.png as xxx.png from archive to basedir/extracted path
    $ unarchive("images/photo.png", "extracted/xxx.png")