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.


rpa ファイルを展開する

このスクリプトを利用することで、rpa ファイルから特定のファイルを抽出できます。これは、例えばプレイヤーに特典を与えるときに利用できます。

スクリプト

init python:
    def unarchive(original_filename, new_filename):
        # original_filename は、ファイルがアーカイブ化される前のパスを指します。
        # new_filename は展開先のパスを指し、ベースのディレクトリーからの相対パスとなります。
        
        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:
    # アーカイブ内に Track01.mp3 と images/photo.png の2つのファイルがあったとします。
    
    # 次は、Track01.mp3 を ベースディレクトリー内の extracted というフォルダーに展開します。
    $ unarchive("Track01.mp3", "extracted/Track01.mp3")
    
    # 次は、images/photo.png を ベースディレクトリー内の extracted というフォルダーに
    # xxx.png という名前で展開します。
    $ unarchive("images/photo.png", "extracted/xxx.png")