Ren'Py SCRIPT

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,101
16,560
But How would adding a third label stop option 1 from saying both options?
It don't.

"If there is no jump statement at the end of the block associated with the label, Ren'Py will continue on to the next statement."
It's from the official documentation " " part.


And so if I start a new line that’s indented the game recognizes that it’s a new block of code?
No, yes, it depend.

"Indentation is used to group statements into blocks. A block is a group of lines, and often a group of statements. The rules for dividing a file into blocks are:
  • A block is open at the start of a file.
  • A new block is started whenever a logical line is indented past the previous logical line.
  • All logical lines inside a block must have the same indentation.
  • A block ends when a logical line is encountered with less indentation than the lines in the block.
Indentation is very important to Ren'Py, and cause syntax or logical errors when it's incorrect. At the same time, the use of indentation to convey block structure provides us a way of indicating that structure without overwhelming the script text."
And this come from the official documentation " " part.

The only things potentially confusing here are :
  • The statement starting a block must end with : ;
  • Not everyt statements need of a block, refer to the statement description to know if it need one or not ;
  • Some statements have optional need of a block, once again refer to the statement description to find if it's the case for this one or not.
Yet, by going further on the documentation and looking at the example, it's relatively easily understandable.


It's the third time I advice you to read the documentation, personally I'll not do it a fourth time.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,619
2,276
[...] How would adding a third label stop option 1 from saying both options?
There is also a jump added in there to use the new label. That is the "why".

And so if I start a new line that’s indented the game recognizes that it’s a new block of code?
I want to say "yes... sort of".

It's certainly the easiest way to think about it.

But a more complete answer is that lines indented (at the same level) are directly linked to the line above with the colon on it. It's the colon that creates the need for a block and the indentation itself that sets out what the block is. So Yes... I guess.

I tend to think of it as "these things belong together". But then my familiarity is what lets me know what belongs together and what doesn't. And as I pointed out with the extra labels, things don't just end because the block of code ends. Though that too, it's probably easier to think that things just pass to the next block down - though as my previous reply hints at, I tend to think of it more as the next line down rather than the next block. Both are probably right - so pick an answer that makes sense in your own head and stick with it until proven wrong.

Honestly, I think you just need to play around with it more and not just assume that something that's "almost the same" is "the same". Almost doesn't count with programming languages.
If you're struggling with the documentation, then maybe look at the source code of uncompressed games. Pick a few simple ones at random, download them and look for .rpy files. If you don't see any in the /game/ folder, pick another game and try again. Rinse and repeat until you find a game simple enough that you can follow it.
 
Last edited: