renpy/doc/cookbook/Unarchiving files from rpa
From Ren'Py Visual Novel Engine
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 = file(new_filename, "wb") new.write(orig.read()) 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")
