code, howto, Ren'Py

Working with Ren’Py: Part 2: Editing and Creating Characters

1_Logo

Working with Ren’Py:

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.

Characters

In Ren’Py, characters are a core part of how stories work. They say different things the player can read. In general, characters can be thought of in two large, loose categories of narration or defined.

Narration

1_Narrator

Statements that are not assigned to a speaker can be thought of as narration. Instead of having a named associated with the text, it is shown by itself. Like reading a story in another medium, such statements can help provide insight into the mind of the protagonist or simply help establish the context of past or future dialogue.

In the above image taken from “The Question”, the narration is the following.

“It’s only when I hear the sounds of shuffling feet and supplies being put away that I realize the lecture’s over.”

This helps explain the context for the player. They are the “I” in the statement, and along with the image of a classroom, can begin to put together that the character might be a student or teacher and that the lecture they attended is not finished.

Defined

2_Speech

Defined characters differ from more general narration in that they have one or more names associated with their statements. In such cases, a character is saying something.

In the above image taken from “The Question”, a defined character named Sylvie is saying the following:

“Hi there! How was class?”

The name of the defined character is shown with the text of their statement to show that they are saying it. Characters can have dialogue with each other by showing their names by each statement they make.

Editing Characters

3_TheQuestion

Open the Ren’Py Launcher and select “The Question” from the Projects listing on the left-hand side. On the right-hand side, click on “script.rpy” under the Edit File options.

“The Question” is an example included in many version of Ren’Py to teach people how to write code, create characters, and manage different parts through a visual novel.

4_Characters

Opening up of the “script.rpy” file of “The Question” shows all of its code. While some parts are straightforward, others require some advanced knowledge of how Ren’Py understands variables and labels.

To start to understand “The Question”, look at the first three lines. It starts with a code comment, something added by developers to help them and others understand the context of the code around it, and then two following lines defining characters.

Since Ren’Py is based on Python, the keyword define is used to connect a value to the name of a variable. In the second line, the variable s is set to the value of a Character named “Sylvie” whose text color is to be “#c8ffc8”.

When the variable s is used in the code after being defined here, Ren’Py will understand that it is equal to the character named “Sylvie” and show that name in the color specified.

5_Changed

Changing Names

Changing the name of a Character is as simple as changing the text used to defined its name. In the above image, the text was changed from “Sylvie” to “Susan”.

6_Susan

After changing the name and saving the “script.rpy”, the difference appears when clicking on “Launch Project” in the Ren’Py Launcher and moving through the visual novel again. Now, instead of “Sylvie”, the character’s name is “Susan”.

Changing Narration

While changing names and colors in how they are defined can make a difference in how characters are presented, changing narration is much simpler.

7_Narration

Lines 18 – 26 in “script.rpy” of “The Question” demonstrate an example of narration. Through using statements in quotations, Ren’Py understands each separate line as something that is said. Since they do not have a name associated with them, they are shown without one.

1_Narrator

Like with changing the name of a character, narration can be changed by changing the text. Changing the existing text —

“It’s only when I hear the sounds of shuffling feet and supplies being put away that I realize that the lecture’s over.”

 — to the following —

“I woke up suddenly as other students were packing up their things around me. I had fallen asleep in the class. Again.”

— changes it in the visual novel once the file is saved.

7_Narration

When the visual novel is launched again, the text has been changed.

9_NewNarrationChanged

Creating Characters

Like with editing existing character, creating new ones requires adding new code to the “script.rpy” file.

10_NewCharacter

In the above image, a new character named “Dan” is added with the text color of “#ccc8ff”. It is defined as the variable d.

In order for a character to say something, its variable must proceed the statement to speak.

11_Dialogue

Lines 58 – 68 of “The Question” show an example of dialogue between two characters. The “s” on line 58 shows that “Susan” is speaking the line “Hi there! How was class?” and the “m” is responding with “Good…”. The third statement, line 63, does not have a variable in front of it and therefore is narration.

In order for the new character Dan to speak a line, it must be added with the variable d in front of it.

12_CharacterSpeech

Now, with new line 20, the character of Dan defined as d is saying the statement “Hey! Wake up!”.

13_DanSpeaks

Through rewriting their name and text, existing character’s information and statements can be changed. To create new characters, define them at the beginning of the code and then use their variable name before some statement to have them say it.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s