|
1.
|
|
|
Persistent Data
|
|
|
|
永続データ
|
|
Translated and reviewed by
Koichi Akabe
|
|
|
|
Located in
../../source/persistent.rst:5
|
|
2.
|
|
|
Ren'Py supports persistent data, saved data that is not associated with a particular point in a game. Persistent data is accessed through fields of the persistent object, which is bound to the variable ``persistent``.
|
|
|
|
Ren'Py は永続データをサポートしており、特定のゲームに依存しないデータをセーブ出来ます。永続データは persistent オブジェクトのフィールドからアクセス出来、変数 ``persistent`` に代入されています。
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:7
|
|
3.
|
|
|
All data reachable through fields on ``persistent`` is saved when Ren'Py terminates, or when :func:`renpy.save_persistent` is called. Persistent data is loaded when Ren'Py starts, and when Ren'Py detects that the persistent data has been updated on disk.
|
|
|
|
``persistent`` のフィールドからアクセス出来るすべてのデータは Ren'Py が終了するか、 :func:`renpy.save_persistent` が呼び出されたときに保存されます。永続データは Ren'py 起動時と永続データがディスク上で更新された時にロードされます。
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:12
|
|
4.
|
|
|
The persistent object is special in that an access to an undefined field will have a None value, rather than causing an exception.
|
|
|
|
persistent オブジェクトは特別で、未定義のフィールドにアクセスすると、例外を出力する代わりに None を返します。
|
|
Translated and reviewed by
Koichi Akabe
|
|
|
|
Located in
../../source/persistent.rst:17
|
|
5.
|
|
|
An example use of persistent is the creation of an unlockable image gallery. This is done by storing a flag in persistent that determines if the gallery has been unlocked, as in ::
|
|
|
|
永続データの使用例はアンロック可能なイメージギャラリーの作成です。これはギャラリーがアンロックされているかどうかのフラグを永続データに置くことで行われます。 ::
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:20
|
|
6.
|
|
|
When the user gets an ending that causes the gallery to be unlocked, the flag must be set to True. ::
|
|
|
|
ユーザーがギャラリーをアンロックするエンディングに到達したらフラグを True に設定しなければなりません。 ::
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:33
|
|
7.
|
|
|
As persistent data is loaded before the init code is run, persistent data should only contain types that are native to python or Ren'Py. Alternatively, classes that are defined in ``python early`` blocks can be used, provided those classes can be pickled and implement equality.
|
|
|
|
永続データは init ブロック実行前にロードされるので、永続データには Python か Ren'Py のネイティブな型のみが含まれます。あるいは pickle 可能で等号演算子が実装されているなら、 ``python early`` ブロックで定義されたクラスも使用出来ます。
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:38
|
|
8.
|
|
|
Merging Persistent Data
|
|
|
|
永続データの統合
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:44
|
|
9.
|
|
|
There are cases where Ren'Py has to merge persistent data from two sources. For example, Ren'Py may need to merge persistent data stored on a USB drive with persistent data from the local machine.
|
|
|
|
2つのソースから Ren'Py が永続データを統合する必要のある場合があります。例えば、 Ren'Py は USB ドライブにある persistent データとローカルマシンにある persistent データを統合する必要があるでしょう。
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:46
|
|
10.
|
|
|
Ren'Py does this merging on a field-by-field basis, taking the value of the field that was updated more recently. In some cases, this is not the desired behavior. In that case, the :func:`renpy.register_persistent` function can be used.
|
|
|
|
Ren'Py はこの統合をフィールドベースで行ない、最も新しいフィールドの値を採用します。いくつかのケースではこれは望ましい動作ではありません。その場合、 :func:`renpy.register_persistent` 関数が使用可能です。
|
|
Translated and reviewed by
akakyouryuu
|
|
|
|
Located in
../../source/persistent.rst:50
|