The If Statement in Ren’Py


Encountered a little problem in coding… But I solved it!!! Just wanna share my experience! It’s about the points you use throughout your game.

Wondering how the story can lead into different endings? I use points! In Visual Novels, you can declare points and as menu choices appear now and then, choices might have additional points associated with them. And sometimes, choices can subtract points, too (Woah I’m not really good at explaining things, but I’m gonna write this anyway).

Let me show you an easy example that both of our minds can handle and understand. (Mind the indention. They’re a must in coding with Ren’Py)

Let’s say that you were walking in the department store and you saw these cute gloves but you don’t have enough money for it. You were given the choices:


    “(Choice 1) Steal it.”:

        $ badpts += 1

        “You stole it.”

    “(Choice 2) Save money for it.”:

        $ goodpts += 1           

        “You saved money until you have the right amount.”

    “(Choice 3) Stop eyeing it and move on.”:

        “You decided to stop your window shopping.”

There are three choices: If you want to steal, to save money, or to just move on. Notice that I used the words “badpts” and “goodpts” besides the “$” sign. These dollar signs are used for the statement of points. Besides the dollar sign is the name of a certain point. You can name it with whatever you want to name it, though. The sentence under each choices or under the point statements are the words that will appear once you clicked a choice during the game.

In this scene, I used the easiest term. If your badpts increase, you’ll receive a very bad ending. If the goodpts increase, there’s no doubt that it’s the good ending you’ll be landing on. So badpts are literally bad points and goodpts are the good points… Just for easy typing, I created a shorter name for the two different points.

However, if you chose the third choice, there’s no additional points in either goodpts or badpts. A choice where nothing happens. And if I want to add another ending besides the good and bad, I can include a Neutral ending.

Let’s say there’s another scene after window shopping. You saw a wallet on the ground. Choices are:


                    “(Choice 1) Take it and keep it.”:

                        $ badpts += 1

                        “You found a lot of money inside it and you decided to spend it.”

                    “(Choice 2) Take it and hand it to Lost and Found.”:

                        $ goodpts += 1

                        “You decided to hand it over to authority.”

                    “(Choice 3) Just continue walking and pretend you don’t notice it.”

                        “You decided that you shouldn’t trouble yourself with it.”

If you chose to steal the gloves on the first menu choice, and continued to increase your bad points by choosing to spend the money from the wallet, then your badpts is already 2 by now. This can be stated as:

$ badpts == 2

The same goes for the goodpts. Stated as:

$ goodpts == 2

Wondering why it’s two equal signs? I don’t know myself. 😆 But hey, two equal signs represents the overall points. If you want to add a point, you’ll use “+=” signs beside each other. The same goes when you want to subtract a point. You just use the signs “-=” in opposite of adding points. Though I don’t use the subtraction points because it’ll just make me confused @_@.

Let’s just say that were almost on the story’s ending. You need to state the points now to determine your character’s destiny. Seeing the script below, notice the indention. In coding and script, it’s programmed that the indention takes up four spaces after colons or “:” signs once you press enter (does this make any sense?). So:

if badpts == 2:

    “You became a bad kid. Your parents are so disappointed in you. Bad ending.”

if goodpts == 2:

    “You became a good kid. Your parents praised you for your kindness. Good ending.”

What happens if you chose a good point in the first choice and picked a bad point on the second? Or what if you chose the neutralized choices all the way?…

I tried searching and found out that there’s another command like “if else” or “elif”…

And I was like… “What’s the difference between the two?” I decided to go with the “if else” statement.

if else:

    “You’re a kid that needs to be nurtured more. You’re still clueless with what’s right from wrong.”

Guess what…? “if else” didn’t work for me. Well!!! Time to use that “elif”!


    “You’re a kid that needs to be nurtured more. You’re still clueless with what’s right from wrong.”

Guess what…? WHAT IS WRONG WITH MEEEEEeeeee~ It still didn’t work!!!

So I thought… I’m doing something wrong… Obviously! Time to visit that Documentation!!!

And so I did! And do you know what I’m doing wrong? “elif” doesn’t work the way I wrote it in jEdit. It’s used in points!!!

You use the (less than) “<” and (greater than) “>” signs before the (equal) “=” sign. Say, if all in all you have 1 goodpts and 1 badpts, if you use “elif” like this:

elif badpts <= 1:

    “You’re a kid that needs to be nurtured more. You’re still clueless with what’s right from wrong.”

Say that the badpts in your game is only 1 because of reasons like:

  • You chose a bad point on first choice, then a good point on the second choice or vice versa
  • You chose a bad point on first choice, then a neutral choice on second menu or vice versa

Or say that your badpts is 0 because of the reasons:

  • You chose a good point on first choice and a neutralized choice on the second menu or vice versa
  • You chose two neutralized choices therefore, you don’t have either goodpts or badpts 

Then in this statement: if badpts <= 1

If I translate it to human words 😆 : if badpts is less than one

And your badpts is equal to only 1 or less than 1… Then the normal ending will appear!!!

It’ll work!

You don’t need to write an “elif” for the goodpts… Why? If badpts is equal to 1 or less than 1… Then what does it make the goodpts? If you chose both two good choices, you’ll receive the good ending, no doubt. But what if you didn’t?

What if you have 1 badpts and 1 goodpts? Or 1 badpts and chose the neutralized choice? Or 1 goodpts and chose the neutralized choice?

I’d say it’s all the same. 😀 If your choices aren’t consistent, then both points, the goodpts and the badpts, will receive either 1 or less than 1, meaning 0.

Don’t think too much! I’m just confusing you >U< If someone’s really reading this Hahahaha! ‘Coz if no one does, then no one is confused… Get it?!!!

Anyway, I don’t know what “if else” do. I sure have seen it in some articles, but it doesn’t work for me… Whatever, I’m good with just using “elif”.

I know people don’t know what I’m talking about 😆 But I know people who works on their Visual Novels using the Ren’Py engine knows what I’m talking about!

And that is how, my dear friends, my energy got drained… It’s elif’s fault!!!


2 thoughts on “The If Statement in Ren’Py

  1. random person lol

    Hello! I know this post is old, but I wanted to say thank you. I’m new to Ren’py and I didn’t really understand variables, but this helped me out, so thank you!

    Liked by 1 person

    • fakeexistence

      😀 Glad it helped you, my posts are all over the place and I’m not good at explaining XD There are much more useful posts in the Lemmasoft Forums though, add me there so I can stalk you hoho jk, good luck on your VN and hope I’d get the chance to play it 🙂


Share your thoughts!!! Come on, I know you wanna say something ;)

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

You are commenting using your 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 )


Connecting to %s