Ren'Py SCRIPT

Soccergod2666

Active Member
Sep 21, 2017
754
388
I’m having so much trouble with writing a script, I’m doing exactly what the YouTube tutorials are doing yet it doesn’t do the same on mine I literally am doing it word for word, everything is the same someone please help me learn. Some things works some things don’t ?
 
Last edited:

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
I’m having so much trouble with writing a script, I’m doing exactly what the YouTube tutorials are doing yet it doesn’t do the same on mine I literally am doing it word for word, everything is the same someone please help me learn. Some things works some things don’t ?
You are going to have to be specific, we can help you but cannot read your mind. Like what are you having trouble with, what tuts are you watching, someone may be able to point you to better ones.
 

OscarSix

Active Member
Modder
Donor
Jul 27, 2019
829
6,671
I’m having so much trouble with writing a script, I’m doing exactly what the YouTube tutorials are doing yet it doesn’t do the same on mine I literally am doing it word for word, everything is the same someone please help me learn. Some things works some things don’t ?
Send us a screenshot of your script and what is going wrong or not working as you intend.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
Some things works some things don’t ?
Yes.

What you need to understand is that Ren'py evolved a lot over times, and most of the tutorials you can found are outdated. Mostly there's backward compatibility, but it's not a constant, and sometime the difference can just come from something that changed in the configuration.
 
  • Like
Reactions: mickydoo

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
Unfortunately you've not really given us enough information to work with.

It could be a simple typo in a critical line or a complete misunderstanding of what you are seeing on the videos.
... or as Anne says... perhaps time has moved on and the thing you are trying to do... doesn't work that way any more.

Is it something specific that isn't working?
... Or is it that the game generates errors and won't actually run?

Is it a specific part of your game that doesn't work how you expect?
... Or does nothing work?

If it's still in it's early stages... and it's a pretty simple game... just upload the script.rpy file here as an attachment. (Assuming that 99% of your code is in that one file). Yeah, it'll be pretty much a spoiler for your future game... but at least we can tear into it and figure out what might be going wrong. It shouldn't matter that all the pictures are missing... unless it's the pictures you are having problems with.

If you've written a lot of code... or worse, you've cut and paste a lot of code from somewhere else... Well... you could upload that too. It'll be a bigger spoiler, but if that's where the problem lies... that what we need to be looking at. If you've split the code across multiple files, either upload them individually or archive them as a .ZIP, .RAR or .7z file and upload the archive.

However, if it's something specific... perhaps try describing exactly what you are having problems with. Maybe provide links to the videos you're watching. And maybe cut and paste the specific lines of code you are having problems with to here on the forums using code tags:

[code=python]
# put your code here.
[/code]

We'll each try to help in our own little special ways... but we need something beyond "it's broke" to figure out the problems.
 

Soccergod2666

Active Member
Sep 21, 2017
754
388
Unfortunately you've not really given us enough information to work with.

It could be a simple typo in a critical line or a complete misunderstanding of what you are seeing on the videos.
... or as Anne says... perhaps time has moved on and the thing you are trying to do... doesn't work that way any more.

Is it something specific that isn't working?
... Or is it that the game generates errors and won't actually run?

Is it a specific part of your game that doesn't work how you expect?
... Or does nothing work?

If it's still in it's early stages... and it's a pretty simple game... just upload the script.rpy file here as an attachment. (Assuming that 99% of your code is in that one file). Yeah, it'll be pretty much a spoiler for your future game... but at least we can tear into it and figure out what might be going wrong. It shouldn't matter that all the pictures are missing... unless it's the pictures you are having problems with.

If you've written a lot of code... or worse, you've cut and paste a lot of code from somewhere else... Well... you could upload that too. It'll be a bigger spoiler, but if that's where the problem lies... that what we need to be looking at. If you've split the code across multiple files, either upload them individually or archive them as a .ZIP, .RAR or .7z file and upload the archive.

However, if it's something specific... perhaps try describing exactly what you are having problems with. Maybe provide links to the videos you're watching. And maybe cut and paste the specific lines of code you are having problems with to here on the forums using code tags:

[code=python]
# put your code here.
[/code]

We'll each try to help in our own little special ways... but we need something beyond "it's broke" to figure out the problems.
Yes.

What you need to understand is that Ren'py evolved a lot over times, and most of the tutorials you can found are outdated. Mostly there's backward compatibility, but it's not a constant, and sometime the difference can just come from something that changed in the configuration.
Send us a screenshot of your script and what is going wrong or not working as you intend.
some girls video i watched from 5 years ago has this exact thing and yet it works for her but not me, from what i see only the "no": is the problem
 

Soccergod2666

Active Member
Sep 21, 2017
754
388
yes i know 5 years ago but the most recent one from 2 years ago he's doing the same thing as her.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
[...] from what i see only the "no": is the problem
Because the "yes" is way too indented.
It's :
Code:
    menu:
        "no":
            jump bobno
                "yes":
            jump bobyes
while it should be :
Code:
    menu:
        "no":
            jump bobno
        "yes":
            jump bobyes
Indentation are really important in Ren'py, because it's why define the content of a block.
 

Soccergod2666

Active Member
Sep 21, 2017
754
388
Because the "yes" is way too indented.
It's :
Code:
    menu:
        "no":
            jump bobno
                "yes":
            jump bobyes
while it should be :
Code:
    menu:
        "no":
            jump bobno
        "yes":
            jump bobyes
Indentation are really important in Ren'py, because it's why define the content of a block.
Okay I fixed it but now it says this?
 

OscarSix

Active Member
Modder
Donor
Jul 27, 2019
829
6,671
Okay I fixed it but now it says this?
What it should be:
Python:
menu:
    "no":
        jump bobno
    "yes":
        jump bobyes
label bobno:
    "girl walks away"
label bobyes:
    "girl strips naked and bends over" #Cant see what content you have after so made my own :D
Indentation and syntax is very important.
- Use ":" to start a new block of code, in your example after the labels but not after the jump.
- Use 4 spaces to indent code correctly
 

Soccergod2666

Active Member
Sep 21, 2017
754
388
What it should be:
Python:
menu:
    "no":
        jump bobno
    "yes":
        jump bobyes
label bobno:
    "girl walks away"
label bobyes:
    "girl strips naked and bends over" #Cant see what content you have after so made my own :D
Indentation and syntax is very important.
- Use ":" to start a new block of code, in your example after the labels but not after the jump.
- Use 4 spaces to indent code correctly
Okay so I started a new example script I feel like I won’t learn other than trial and error. So here everything is working but when I chose option1 it says both labels, so I choose option 1 and then it says “you’re smart “ and “you’re intelligent but if I choose option 2 it does what I want it to which is only option 2, do I put return under option 1? As well?
 

Soccergod2666

Active Member
Sep 21, 2017
754
388
Okay so I started a new example script I feel like I won’t learn other than trial and error. So here everything is working but when I chose option1 it says both labels, so I choose option 1 and then it says “you’re smart “ and “you’re intelligent but if I choose option 2 it does what I want it to which is only option 2, do I put return under option 1? As well?
Okay so I figured that out now but what about this. What am I doing wrong here?
 

OscarSix

Active Member
Modder
Donor
Jul 27, 2019
829
6,671
Okay so I started a new example script I feel like I won’t learn other than trial and error. So here everything is working but when I chose option1 it says both labels, so I choose option 1 and then it says “you’re smart “ and “you’re intelligent but if I choose option 2 it does what I want it to which is only option 2, do I put return under option 1? As well?
The reason is says both options because once it jumps to "option 1" it continues down the script to option 2. You either need to jump or add "return" to end the game
 
  • Like
Reactions: Soccergod2666

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
Okay so I started a new example script I feel like I won’t learn other than trial and error.
Well, you can also learn by reading the official documentation available both and offline (in the "doc" sub-directory of Ren'py's SDK). It would be a good point to start, then you can use tutorials to go further and help you to understand what can stay obscure.
 
  • Like
Reactions: OscarSix

Soccergod2666

Active Member
Sep 21, 2017
754
388
"return" ends the game, any content you want in the game needs to be before a return
Okay I’m starting to get it thanks, sorry I don’t want to spam you with question but what is the difference between call and show when referring to pictures?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
Okay I’m starting to get it thanks, sorry I don’t want to spam you with question but what is the difference between call and show when referring to pictures?
Since you don't call a picture, you probably refer to screens, which are something different.
You really should start by reading the documentation.
 

OscarSix

Active Member
Modder
Donor
Jul 27, 2019
829
6,671
Okay I’m starting to get it thanks, sorry I don’t want to spam you with question but what is the difference between call and show when referring to pictures?
Most of these questions are stated in the documentation Anne linked earlier. Please read and if you have any further questions message us then.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
To recap and rephrase some of replies already...

  • Only specific statements lines end with a colon ( : )
Sometimes you've added them to lines like jump {label}:. It'll generate errors.​
It's not always obvious when you start out coding where colons belong. But you'll get there with experience.​
So just keep an eye out for them and learn when they should be used (or not).​
  • Indentation matters... A LOT.
Generally speaking, if a line ends with a colon... the line(s) below it should be indented by 4 spaces.​
Indentation only works when things line up. If you indent by 4, then indent again by 4... RenPy will be looking for that colon (and it won't find it).​
Again, this is going to be an "experience" thing. Once you realize the patterns, you'll rarely make the same mistakes in the future.​
  • return doesn't end an indentation block.
I think you've seen return used in a specific way and misinterpreted why.​
Just "not" indenting the next line ends a block of code related to the colon above it. (So going left by 4 spaces).​
At the level you're programming at right now, you probably want to avoid call and return. They have their uses, but based on the errors you're getting - I think trying to learn how to use them properly will just confuse matters. So for the moment think of return as "end the game" and avoid all other uses.​
  • call and call screen are two very different animals. So are show and show screen.
Continuing on from my previous point, part of the confusion around call is because of it's similarity to call screen. They are two completely different statements, doing two completely different things. If you try to relate one to the other or try to mix and match concepts related to each together... bad things will happen and you'll struggle to see why.​
The same is true for show and show screen. show puts an image onto the screen and leaves it there. show screen puts a screen onto the screen and leaves it there. Beginning to see where the confusion comes from? For the moment, ignore it all.​
  • Code will just continue from one label to another, unless you tell it otherwise.
The game doesn't stop or end just because it's reached the end of an indented block.
It looks to me like you tried to instead use return as an "this block of code ends here". (Nope).
However, what really happens is things just continue, one statement at a time, one line at a time.

So...

Python:
label start:

   "*** The Start ***"
    menu:
        "Option 1"
            jump my_label_one
        "Option 2"
            jump my_label_two

label my_label_one:

    "You picked Option 1"

label my_label_two:

    "You picked Option 2"

    "*** THE END ***"
    return

Will display "You picked Option 2" if you picked option 2... BUT... Will display both "You picked Option 1" AND "You picked Option 2" if you select option 1.

What you more likely would want is:

Python:
label start:

   "*** The Start ***"
    menu:
        "Option 1"
            jump my_label_one
        "Option 2"
            jump my_label_two

label my_label_one:

    "You picked Option 1"
    jump my_label_three

label my_label_two:

    "You picked Option 2"

label my_label_three:

    "*** THE END ***"
    return

Hopefully it makes sense as to why.


One thing I will say is that none of the errors you've described are related to changes in how RenPy works. You said you're doing exactly the same as the tutorial videos... but weren't.

All the words were the same, but the indentations were different.
You'd added colons to lines that didn't need them and failed to add colons where they were required.

Sadly programming languages are pedantic and so those small differences led to the errors you were seeing.

The thing is, the code above it was coded correctly... So if I had to guess, you simply got frustrated and weren't as careful as you had been earlier. No worries... that's how we all learn.
 
Last edited:

Soccergod2666

Active Member
Sep 21, 2017
754
388
To recap and rephrase some of replies already...

  • Only specific statements lines end with a colon ( : )
Sometimes you've added them to lines like jump {label}:. It'll generate errors.​
It's not always obvious when you start out coding where colons belong. But you'll get there with experience.​
So just keep an eye out for them and learn when they should be used (or not).​
  • Indentation matters... A LOT.
Generally speaking, if a line ends with a colon... the line(s) below it should be indented by 4 spaces.​
Indentation only works when things line up. If you indent by 4, then indent again by 4... RenPy will be looking for that colon (and it won't find it).​
Again, this is going to be an "experience" thing. Once you realize the patterns, you'll rarely make the same mistakes in the future.​
  • return doesn't end an indentation block.
I think you've seen return used in a specific way and misinterpreted why.​
Just "not" indenting the next line ends a block of code related to the colon above it. (So going left by 4 spaces).​
At the level you're programming at right now, you probably want to avoid call and return. They have their uses, but based on the errors you're getting - I think trying to learn how to use them properly will just confuse matters. So for the moment think of return as "end the game" and avoid all other uses.​
  • call and call screen are two very different animals. So are show and show screen.
Continuing on from my previous point, part of the confusion around call is because of it's similarity to call screen. They are two completely different statements, doing two completely different things. If you try to relate one to the other or try to mix and match concepts related to each together... bad things will happen and you'll struggle to see why.​
The same is true for show and show screen. show puts an image onto the screen and leaves it there. show screen puts a screen onto the screen and leaves it there. Beginning to see where the confusion comes from? For the moment, ignore it all.​
  • Code will just continue from one label to another, unless you tell it otherwise.
The game doesn't stop or end just because it's reached the end of an indented block.
It looks to me like you tried to instead use return as an "this block of code ends here". (Nope).
However, what really happens is things just continue, one statement at a time, one line at a time.

So...

Python:
label start:

   "*** The Start ***"
    menu:
        "Option 1"
            jump my_label_one
        "Option 2"
            jump my_label_two

label my_label_one:

    "You picked Option 1"

label my_label_two:

    "You picked Option 2"

    "*** THE END ***"
    return

Will display "You picked Option 2" if you picked option 2... BUT... Will display both "You picked Option 1" AND "You picked Option 2" if you select option 1.

What you more likely would want is:

Python:
label start:

   "*** The Start ***"
    menu:
        "Option 1"
            jump my_label_one
        "Option 2"
            jump my_label_two

label my_label_one:

    "You picked Option 1"
    jump my_label_three

label my_label_two:

    "You picked Option 2"

label my_label_three:

    "*** THE END ***"
    return

Hopefully it makes sense as to why.


One thing I will say is that none of the errors you've described are related to changes in how RenPy works. You said you're doing exactly the same as the tutorial videos... but weren't.

All the words were the same, but the indentations were different.
You'd added colons to lines that didn't need them and failed to add colons where they were required.

Sadly programming languages are pedantic and so those small differences led to the errors you were seeing.

The thing is, the code above it was coded correctly... So if I had to guess, you simply got frustrated and weren't as careful as you had been earlier. No worries... that's how we all learn.
Okay you’ve explained it very well I’m starting to get the hang of it now I appreciate all the help. But How would adding a third label stop option 1 from saying both options? And so if I start a new line that’s indented the game recognizes that it’s a new block of code?