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.
Ren'Pyは永続的データをサポートし、それはゲームの特定の場所に関係なくセーブされます。 永続的データはpersistentオブジェクトの属性を通してアクセスされるデータです。
永続的変数は必ず特別なpersistentオブジェクトに所属します。persistentの属性を通してアクセス可能なすべてのデータは Ren'Py停止時にセーブされ、Ren'Py再開時にロードされます。persistentオブジェクトは特別にその未定義の属性に対する アクセスは、例外を起こす代わりにNoneになります。
永続的データの使用例は、アンロック可能なイメージギャラリーの作成です。 次のように、これはpersistentにフラグを保存し、ギャラリーがアンロックされたかを決めます。
label gallery:
if not persistent.gallery_unlocked:
show background
centered "You haven't unlocked this gallery yet."
$ renpy.full_restart()
# Actually show the gallery here.
ユーザーがギャラリーをアンロックするエンディングにたどり着いたら、フラグを真にしなければいけません。:
$ persistent.gallery_unlocked = True
ゲーム間永続的データはRen'Pyゲーム間で情報を共有させる機能です。これは、シリーズ物のゲームを計画し、それらに情報を 共有させたいなら有益です。
ゲーム間永続的データを使用するためには、MultiPersistentオブジェクトがinitブロック内で作られなければなりません。 ユーザーはこのオブジェクトを更新でき、そのセーブメソッドを呼び出せば、ディスクにセーブ出来ます。 未定義の属性はデフォルトでNoneです。オブジェクトがもう一度ロード可能だと保証するために、ユーザー定義型のインスタンスを 代入しないことを勧めます。
新しくゲーム間永続的データを作成します。これはinitブロックでのみ呼び出されるべきで、keyに対応する新しいMultiPersistentオブジェクトがを返します。
keyはゲーム間永続的データにアクセスするために使われるキーです。衝突を避けるために、あなた自身のドメインで修飾されるべきです。 例えば、renpy.orgを所有しているなら、"demo.renpy.org"をキーに使えます。
MultiPersistentオブジェクトをディスクにセーブしてください。このメソッドが呼び出されるまで、変更は永続的ではありません。
Example. 複数パートのゲームのその1
init:
$ mp = MultiPersistent("demo.renpy.org")
label start:
# ...
# Record the fact that the user beat part 1.
$ mp.beat_part_1 = True
$ mp.save()
e "You beat part 1. See you in part 2!"
その2:
init:
$ mp = MultiPersistent("demo.renpy.org")
label start:
if mp.beat_part_1:
e "I see you've beaten part 1, so welcome back!"
else:
e "Hmm, you haven't played part 1, why not try it first?"
Data Location. データが置かれる場所は、使われているOSにより違います。: