Skip to content

Persistent data ​

This page is part of the GenPy Ren'Py learning path. It focuses on practical Ren'Py 8.x production and links each concept back to the GenPy workflow.

Learning goals ​

  • Choose persistent data only for cross-save state.
  • Initialize persistent fields safely.
  • Plan migration for older player data.

Core syntax ​

  • persistent
  • default persistent
  • achievement
  • renpy.seen_label

Runnable example ​

text
# 读写 persistent.<名字>,自动持久化到磁盘
$ persistent.cleared_chapter1 = True

label start:
    if persistent.cleared_chapter1:
        "欢迎回来,老玩家。"

Study outline ​

  • Start with the smallest example for persistent data.
  • Test the key terms in a clean Ren'Py project: persistent, default persistent, achievement, renpy.seen_label.
  • Move the pattern back into your real project only after the example runs.
  • Use GenPy docs and validation to keep the feature connected to story, assets, and export readiness.

Common pitfalls ​

  • Test the smallest working script before layering on visual or UI complexity.
  • Run Ren'Py Lint before release builds, even when the script appears to run locally.
  • Keep examples in standard .rpy files so they remain editable outside GenPy.

Official references ​

How this fits in GenPy ​

  • Use Variables to document which state is save-specific and which is persistent.
  • Use plugin docs when achievements or galleries become project systems.

Recommended GenPy docs:

Built for GenPy creators.