Skip to content

Conditionals ​

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 ​

  • Write readable conditional branches.
  • Avoid unreachable choices and accidental infinite loops.
  • Connect conditionals to variables and validation checks.

Core syntax ​

  • if
  • elif
  • else
  • while
  • break
  • continue

Runnable example ​

text
default money = 50

label shop:
    if money >= 100:
        e "你很有钱!"
    elif money >= 10:
        e "还过得去。"
    else:
        e "你身无分文。"

Study outline ​

  • Start with the smallest example for conditionals.
  • Test the key terms in a clean Ren'Py project: if, elif, else, while.
  • 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 state names and Validation to catch branch mistakes before export.
  • Use Story Graph when conditions reshape the route map.

Recommended GenPy docs:

Built for GenPy creators.