renpy/doc/tutorials/Ren'Py Script Structure - Ren'Py

documentation index

## 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

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."

Previous: Thinking in Ren'Py | Ren'Py Web Tutorial | Next: Defining Characters

documentation index