Ren’Py + Python: Part 1: Setting and Using Flags


Working with Ren’Py:

Advanced Ren’Py:

Customizing Ren’Py:

Ren’Py + Python:

Ren’Py is a engine for creating visual novels. It comes with a suite of tools for taking code and transforming it into programs that can be run on Windows, Mac, Linux, and even, with a little more work, mobile platforms like Android and iOS.

Beyond the showing of text and images, Ren’Py can also be extended through introducing new user interface elements, changing its defaults images, and combining Python with its own code to create even more interactive projects.


Setting Flags

In visual novel terminology, a “flag” is some type of signal that tells a project to go down a new path or do something different than it would have normally done. In Ren’Py, a “flag” is a variable created in Python and used in conjunction with conditional statements.

Screenshot 2018-07-23 10.34.48

Because flags are variables in Python, this also means that all data types are available. Everything from simple integers to more complex dictionaries can be used as part of a project in Ren’Py.


Using Flags with Conditional Statements

Screenshot 2018-07-23 10.41.55

Once created, variables can be used as part of conditional statements. Beyond testing if a boolean is true or false, other comparisons can be carried out as well.

Screenshot 2018-07-23 11.04.39


Updating Flags

Screenshot 2018-07-23 11.08.17

As variables, flags can also be updated. However, as Python is separate from Ren’Py’s own dialect, any lines containing Python code need to start with a dollar sign, $.

Screenshot 2018-07-23 11.08.54



Through combining variables with other functionality in Ren’Py, it is possible to create repeating dialogue actions that loop based on a value.

In this example, a single menu choice “Climb the stairs” repeats as long as the value of steps is less than four.

Screenshot 2018-07-23 11.29.09

GitHub Gist Version:


define steps = 0
label start:
"You see a long set of stairs leading up in front of you."
"You begin climing them."
label climbStairs:
if steps >= 4:
jump stairsTop
"The stairs continues upward."
$ steps += 1
"Climb the steps":
jump climbStairs
label stairsTop:
"You made it to the top of the stairs!"

view raw


hosted with ❤ by GitHub