Ren'Py Tutorial: How to Create Characters and Write Dialogue

Learn how to define characters, customize dialogue colors and write conversations in Ren'Py. A simple guide with code examples for your first visual novel.

Now that you have your Ren'Py project set up, it's time to start adding some characters and writing your story!

Characters and dialogue are probably going to be a big part of your visual novel, so let's go through how to create character definitions, write conversations, customize dialogue colors and handle narration.

If you've followed our previous tutorial, you should already have a basic Ren'Py project ready. If not, you can start with our Beginner Ren'Py Tutorial.

Let's get started!

1. Creating Your First Character

Before writing any dialogue, we need to tell Ren'Py which characters will appear in our game.

Open your script.rpy file. You should see something similar to this:


# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene bg room

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    show eileen happy

    # These display lines of dialogue.

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return

We're going to add our character definitions above label start:.

For example, let's create two characters:

define e = Character("Eileen")
define m = Character("Mika")

That's it! We've just created two characters. (e is usually already defined)

Here's what each part means:

  • define tells Ren'Py to create a character definition.
  • e and m are the names we'll use to refer to these characters in our script.
  • Character() creates a new character.
  • "Eileen" and "Mika" are the names that will appear in the namebox.

You can name the variables whatever you want. I personally prefer using short names because they make writing longer scripts a little easier.

You can also use the full character name as the variable:

define eileen = Character("Eileen")
define mika = Character("Mika")

Both methods work exactly the same way.


2. Writing Character Dialogue

Now that we have our characters, let's make them talk!

Add the following code underneath label start:

label start:

    e "Hey! How are you doing today?"

    m "I'm doing pretty well. What about you?"

    e "I'm great! I was actually looking for you."

    m "Oh? Is something wrong?"

    e "Not really. I just wanted to talk."

    return

When you launch the game, you'll see the characters' names appear above the dialogue box, and their dialogue will be displayed one line at a time.

A character speaks whenever you use their variable followed by a string of text.

For example:

e "Hello!"

This tells Ren'Py that Eileen is speaking.

Pretty straightforward, right?

You can write as many dialogue lines as you want, and Ren'Py will automatically move to the next line when the player clicks or presses the appropriate key.


3. Writing Narration

Not every line in your visual novel needs to come from a character.

Sometimes you'll want to describe what's happening, introduce a scene or let the player read the protagonist's thoughts.

For this, you can simply write dialogue without specifying a character:

label start:

    "It was a quiet afternoon."

    "The sun was slowly disappearing behind the buildings."

    e "You've been standing here for a while."

    m "Oh, sorry. I was just thinking about something."

    return

These lines are called narration.

By default, narration doesn't display a character name in the dialogue box.

You can also use narration to describe character actions or expressions:

e "I didn't expect to see you here."

"The girl looked away, trying to hide her smile."

e "Anyway... what brings you here?"

This is especially useful when you're writing a visual novel with a lot of descriptive text.


4. Customizing Character Dialogue Colors

One small detail that can make your visual novel feel much more polished is giving each character their own dialogue color.

For example, you might want Eileen's name to appear in pink and Mika's name in blue.

You can do this directly in your character definitions:

define e = Character("Eileen", color="#E8A0BF")
define m = Character("Mika", color="#9DBCE8")

The color property controls the color of the character's name in the dialogue box.

You can use regular HEX color codes to match your game's color palette.

Here are a few examples you can try:

ColorHEX Code
Pink#E8A0BF
Blue#9DBCE8
Green#A8DCC5
Brown#C99B78

Personally, I think using slightly muted colors instead of very bright ones usually works better for visual novels. It also makes the interface easier to look at during longer reading sessions.


5. Changing Dialogue Text and Character Name Styles

What if you want to customize more than just the character name color?

Ren'Py also allows you to customize character names and dialogue using text tags.

For example, you can make certain words bold or italic:

e "I have something <b>important</b> to tell you."

m "Really? <i>What is it?</i>"

Here are some useful text tags:

TagWhat It Does
<b>text</b>Makes text bold
<i>text</i>Makes text italic
<u>text</u>Underlines text
{color=#FF0000}text{/color}Changes text color
{size=40}text{/size}Changes text size

You can also combine multiple tags:

e "This is <b><i>really important!</i></b>"

Just remember to close your tags properly, or you might end up applying the formatting to more text than you intended.


6. Adding Character Emotions to Dialogue

Another useful feature is changing a character's appearance depending on their emotions.

For example, you might have different character sprites for happy, sad, surprised or angry expressions.

Ren'Py can handle this using image attributes.

Let's say you have the following character images:

  • eileen happy.png
  • eileen sad.png
  • eileen angry.png

First, we need to define the images:

image eileen happy = "images/eileen happy.png"
image eileen sad = "images/eileen sad.png"
image eileen angry = "images/eileen angry.png"

Then, we can display them using the show statement:

label start:

    show eileen happy

    e "Hey! It's nice to see you."

    show eileen sad

    e "Actually, I haven't been feeling very well lately."

    show eileen angry

    e "And I'm really tired of pretending everything is fine!"

    return

You can see how the character's expression changes throughout the conversation.

One thing worth mentioning: Ren'Py doesn't automatically know which expression matches the dialogue. You'll need to tell it when to change the sprite.

We'll go into more detail about character sprites, backgrounds and image positioning in our next tutorial!


7. Giving Your Protagonist a Custom Name

If you're making an interactive visual novel, you might want players to enter their own names instead of using a fixed protagonist name.

Luckily, Ren'Py makes this pretty easy.

First, create a variable to store the player's name:

default player_name = "Alex"

Next, create a character definition that uses this variable:

define mc = Character("[player_name]")

Now, let's ask the player for their name at the beginning of the game.

label start:

    $ player_name = renpy.input("What's your name?")

    $ player_name = player_name.strip()

    if player_name == "":
        $ player_name = "Alex"

    mc "Nice to meet you!"

    return

Here's what's happening:

  • renpy.input() opens a text input field where players can enter their name.
  • .strip() removes unnecessary spaces at the beginning and end.
  • The if statement checks whether the player entered anything.
  • If the input is empty, the game uses "Alex" as the default name.

Now, when the character speaks, Ren'Py will automatically display the name entered by the player.

You can also use [player_name] directly inside dialogue:

e "So, [player_name], shall we go?"

This is a really useful feature for otome games, dating sims and other interactive visual novels where players can name their protagonist.


8. Putting Everything Together

Let's put what we've learned into a small example.

We'll create two characters, give them different name colors, add some narration and change one character's expression during the conversation.

You can copy this entire script into your script.rpy file and try it yourself.

define e = Character("Eileen", color="#E8A0BF")
define m = Character("Mika", color="#9DBCE8")

image eileen happy = "images/eileen happy.png"
image eileen sad = "images/eileen sad.png"

label start:

    scene black

    "It was already getting late."

    "I was about to head home when someone called my name."

    show eileen happy

    e "Hey! Wait a second!"

    m "Oh, Eileen! I didn't see you there."

    e "I was wondering if you'd like to come with me."

    m "Where are we going?"

    show eileen sad

    e "Well... that's kind of a surprise."

    m "You're acting a little suspicious."

    show eileen happy

    e "Just trust me!"

    return

Make sure you have the two character images in the correct folder, or Ren'Py will report an image-not-found error. If you haven't prepared any sprites yet, you can temporarily remove the image and show statements and test the dialogue on its own.

And there you have it! You've got a simple conversation between two characters.


9. A Few Things to Keep in Mind

Before you start writing a full visual novel, here are a few small tips that might save you some trouble later:

Keep character definitions organized.

If your game has several characters, it's a good idea to put all their definitions in one place instead of scattering them throughout your scripts.

You can create a separate file, such as characters.rpy, and keep your character definitions there. Ren'Py automatically loads .rpy files inside the game folder, so you don't need to manually import them.

Use consistent variable names.

Try to stick to one naming convention. For example, use e for Eileen throughout your entire project instead of switching between e, eileen and char_e.

Test your dialogue frequently.

It's easy to write a lot of dialogue without noticing small formatting problems. I usually recommend testing your game every now and then instead of waiting until an entire scene is finished.

Don't worry about making everything perfect right away.

When you're just starting out, focus on getting your story and basic game structure working first. You can always come back and improve the dialogue box, fonts and character sprites later.


What's Next?

We've covered the basics of character definitions, dialogue, narration and a few ways to customize how your characters appear in-game.

In the next tutorial, we'll take a closer look at images in Ren'Py, including how to add background images, character sprites and different character expressions.

If you're interested in making your own visual novel, feel free to follow along with the rest of our Ren'Py tutorials!



Need a Little Help With Your Visual Novel?

Working on a visual novel is fun, but not every part of development has to be done alone.

At YoruBox, we work on indie visual novels and can help with Ren'Py scripting, custom UI design and other small game development tasks.

If you need a custom dialogue interface, help implementing a game feature or just want to give your game a more personalized look, feel free to contact us!

yorubox.team
yorubox.team
Articles: 9

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newsletter
This field is required.