This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


Ren'Py Script Structure

Init Blocks

Every Ren'Py script has information, such as characters, images, and music which you need to declare outside of the story. This is done with init blocks. An init block looks like this:

init:
    $ john = Character("John Smith")
    $ percy = Character("Sir Percival Blakely")

    image black = "#000000"

Later sections will explain what goes in the init block, for the moment we're just pointing out what they look like. They can come anywhere in a file, but it's generally best to put them at the top. Init blocks are not indented, and the statements following an init block which are indented are in that init block. Once you type a statement (usually a label) which is not indented, the init block is finished. You can have any number of statements in an init block.

And that's all you need to know about them for now.

Labels

Labels allow you to give names to points in your story. Using them to change the flow of your story is discussed in ../Branching & Recombining the Story/. Right now, the important thing to know is that every Ren'Py script has to have one label in it, called "start". That's where Ren'Py starts executing your story. It looks like this:

label start:

So, generally, the beginning of a simple Ren'Py script would look like:

init:
    $ j = Character("John")

label start:
    j "Hello, World!"

Comments

You will occasionally see comments in a Ren'Py script explaining what a line in the script is for. Comments look like this:

 # lines that start with an octothorpe (a.k.a. a number sign, 
 # hash, or sharp) are comments. If you want to have comments
 # continue over several lines, you have to put the hash mark
 # at the start of each line.

People playing Ren'Py games never see comments, they're only for you and anyone collaborating with you on a Ren'Py game. Ren'Py ignores comments, so you can put anything that you like in them. They're also useful for removing lines from the story which you're not ready to lose forever:

# j "Nice shoes, Jen."

Multiple files

As your game gets bigger, you might decide to split the game file up, to make it easier to find things without all that scrolling. You can call the files whatever makes sense to you, but they must be in the "game" folder for that project, and must end with the extension ".rpy"

Category: Ren'Py Web Tutorial