Working with Ren’Py: Part 4: Menus, Labels, and Jumps

1_Logo

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.

 

Menus

1_Menu

In Ren’Py menus are central to how in-game choices are presented. By choosing one option in “The Question” (shown above), the player is moved (jumped) from one section of code to another.

3_TheQuestion

Open the “script.rpy” file from “The Question”.

2_MenuCode

Lines 43 – 56 demonstrate how a menu is used. Choices are under (indented) the menu and their own code is then under (indented) the text of the choice.

The keyword menu, however, only works in the above example because because it is part of two other keyword functionality: labels and jumps.

Label

Code in the “script.rpy” file of a project in Ren’Py can be divided up into sections. These are called labels.

3_LabelStart

After characters are created and other initialization tasks are complete, Ren’Py starts a project at the label start. In the “script.rpy” file of “The Question”, this is line 12.

Labels are also be found in other places and with other names.

4_LabelRightaway

For example, the label rightaway is found on line 57. It is the beginning of a new section of code and immediately follows the previous menu code. In “The Question”, it is the first of two possible paths from the in-game choices.

It is accessed through another keyword, jump.

Jump

The jump keyword is used to move from one label to another. It “jumps” to that new section of code.

2_MenuCode

In “The Question”, it appears first on lines 50 and 54. Depending on what the player chooses, they are “jumped” to either the label rightaway or the label later.

Removed from any code, Ren’Py would “read” the project start to finish depending on the order of the code in the file. With using the keyword jump, projects in Ren’Py can loop, branch, and create new paths.

Menus, Labels, and Jumps

The menu keyword can be used to create in-choices. Through using existing labels, a player can be moved (jumped) from one section to another.

2_MenuCode

In “The Question”, this combination is used on lines 43 – 56  —

5_MenuCodeAgain

— and again on lines 100 – 111. Each use the menu keyword is combined with the jump keyword to move the player to different labels.