Any thoughts for an "introduction to RenPy" style tutorial?

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
[...] was to do a few actual basic Python tutorials. The pure coding helped me understand a few fundamentals that transfer to Ren'Py and made me understand what I was doing and why. [...]
It's probably the most important missing part of the official doc. Not a full coding course, but an introduction to the coding structure. Despite being really simple, Ren'py is still a coding language, and it would probably offer a better understanding of the documentation to open this door.

Take the basic, "a line ended by ':' introduce a block", which is a fundamental notion, by example. As far as I remember, the doc only say that it introduce a block and that you have to indent the line. This while it should also explain what is a block, why you have to indent its content, and why it's so important to do so.
Which lead many dev's to write things like :
Code:
label start:
scene myScene
mc "blablabla"
And like it works, they don't look further, and end with a code that works, but only because Ren'py is very flexible. If PyTom break this flexibility while refactoring Ren'py when he port it to Python 3.x, and many dev will loose all bearings, not understanding why suddenly nothing works.
In the same time, this notion of block permit to explain why you have to end a label by a jump or return, and small things like that, which are the answer to many thread created here.


There is actually a ready to use and "relatively" easy to understand example in the renpy .
FranceToast , if you need, there's also the explanation and code wrote by Rich , explaining the in-game gallery system.
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
It's probably the most important missing part of the official doc. Not a full coding course, but an introduction to the coding structure. Despite being really simple, Ren'py is still a coding language, and it would probably offer a better understanding of the documentation to open this door.

Take the basic, "a line ended by ':' introduce a block", which is a fundamental notion, by example. As far as I remember, the doc only say that it introduce a block and that you have to indent the line. This while it should also explain what is a block, why you have to indent its content, and why it's so important to do so.
Which lead many dev's to write things like :
Code:
label start:
scene myScene
mc "blablabla"
And like it works, they don't look further, and end with a code that works, but only because Ren'py is very flexible. If PyTom break this flexibility while refactoring Ren'py when he port it to Python 3.x, and many dev will loose all bearings, not understanding why suddenly nothing works.
In the same time, this notion of block permit to explain why you have to end a label by a jump or return, and small things like that, which are the answer to many thread created here.




FranceToast , if you need, there's also the explanation and code wrote by Rich , explaining the in-game gallery system.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
Beep ! Error...

Indentation is important, and in fact mandatory, with both Python and Ren'py, because it's how blocks are expressed. Unlike others languages, which use keywords or brackets as markers, in Python and Ren'py, a line is part of a block only due to its indentation.
You don't have permission to view the spoiler content. Log in or register now.

Therefore, it's absolutely not a question of visual formatting, which is the subject of the article you point out, but a question of fundamental structuring. It's not something you can do to ease the reading of your code, but something you have the obligation to do because of the language structure.
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
Beep ! Error...

Indentation is important, and in fact mandatory, with both Python and Ren'py, because it's how blocks are expressed. Unlike others languages, which use keywords or brackets as markers, in Python and Ren'py, a line is part of a block only due to its indentation.
You don't have permission to view the spoiler content. Log in or register now.

Therefore, it's absolutely not a question of visual formatting, which is the subject of the article you point out, but a question of fundamental structuring. It's not something you can do to ease the reading of your code, but something you have the obligation to do because of the language structure.
 

FranceToast

Active Member
Donor
Jul 31, 2018
562
894
FranceToast , if you need, there's also the explanation and code wrote by Rich , explaining the in-game gallery system.
Thank you-I'm a big Rich fan!
Just perusing his code-it seems like I could use this for my card game idea-just make clicking the card icon in the scene open an image, and once that image is shown, it becomes a "renpy.seen_image", and should appear in the specific 'card collection' gallery. Or something, LOL.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
Which is a totally stupid answer. It would need to rewrite the whole code of Ren'py with brackets, or make Ren'py works with two pre-processors, one for the core, one for the game. And anyway you'll still have to rewrite the whole parser of Ren'py, to make it works with brackets.
 

Paz

Active Member
Aug 9, 2016
912
1,449
Aah, it's always refreshing to see people invent new ways to introduce minuscule errors in your code, and try to solve issues any decent IDE/editor solves by itself.
And for the added bonus of a preprocessor on top of it, because you can't have enough abstraction.
 

GNVE

Active Member
Jul 20, 2018
703
1,159
It is at least somewhat funny how the creator says he dislikes indentation and then uses indentation in the code example basically showing why python is (in my eyes) one of the most user friendly and fun to use languages out there. (not that that says much though but coding in Python was the first time I actually found it fun to learn and I could stick with it.)
 

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,961
My problem now is that there are a million and one things to go at next.
If you are aiming for a beginners guide, next step should be all about variables. Adding/subtract points, True/False flags versus numerical variables, and then if/elif/else statements. That's the most logic thing to explain, IMO. Also, how to make different choices appear depending on a variable check (many devs creates different menus, checking the variable BEFORE them and jumping to the 'right' one, when a simple "if" statement next to the choice would do the trick). Related to this, keep your code clean, avoiding unneccessary repetitions of blocks of text; then lists of elements, and so on...Basically one thing leads to another
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
If you are aiming for a beginners guide, next step should be all about variables. Adding/subtract points, True/False flags versus numerical variables, and then if/elif/else statements. That's the most logic thing to explain, IMO. Also, how to make different choices appear depending on a variable check (many devs creates different menus, checking the variable BEFORE them and jumping to the 'right' one, when a simple "if" statement next to the choice would do the trick). Related to this, keep your code clean, avoiding unneccessary repetitions of blocks of text; then lists of elements, and so on...Basically one thing leads to another
Remember that this is a pirate site. So if you want "this function" in your game, you don't always need to write the code yourself, you can pirate it from other games. You see a lot of devs asking questions... how do I make a _____ like in the game Mifly Way and the 3 Muskrateers. The answer is: You don't have to reinvent the wheel, you just jack that game up and snatch the wheels you want off it.

most-of-our-code-the-parts-copied-from-stack-overflow-38269718.png
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,583
2,222
If you are aiming for a beginners guide, next step should be all about variables. Adding/subtract points, True/False flags versus numerical variables [...]
Already in there as of a couple of days ago... I just haven't updated my first post to reflect recent additions.
Similarly text tags for bold, italics and such. Pauses, loose conventions about how text is used and a couple of small items.

[...] and then if/elif/else statements.
I've covered if / else... I may throw elif in later. It's not that it's hard if you have a programmer oriented mind, it just feels like a distraction at this level. I'm trying to avoid introducing stuff someone wouldn't actually NEED yet... and that felt like one of those examples.

Oh, and please include a "make your code translation friendly with the magical _(" ") thing" section in your tutorial.
You're almost certainly right. Problem is I've never done that myself either. I may have a play before finishing the guide and mention it near the end. But I'm hesitant to for two reasons. (1) If I could write a full (simple) game and not know it, then the same is true for the reader - so perhaps can be skipped for a "newbie" guide. (2) I'm not really confident to cover a topic I too don't actually know. It would feel like the blind leading the blind. I've added it to my to-do list now either way.
 

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,961
Remember that this is a pirate site. So if you want "this function" in your game, you don't always need to write the code yourself, you can pirate it from other games. You see a lot of devs asking questions... how do I make a _____ like in the game Mifly Way and the 3 Muskrateers. The answer is: You don't have to reinvent the wheel, you just jack that game up and snatch the wheels you want off it.

View attachment 567344
lol, and that too. It's sooo annoying seeing such questions when the only thing they have to do is to copypaste what already works
 
  • Like
Reactions: polywog

FranceToast

Active Member
Donor
Jul 31, 2018
562
894
You're almost certainly right. Problem is I've never done that myself either. I may have a play before finishing the guide and mention it near the end. But I'm hesitant to for two reasons. (1) If I could write a full (simple) game and not know it, then the same is true for the reader - so perhaps can be skipped for a "newbie" guide. (2) I'm not really confident to cover a topic I too don't actually know. It would feel like the blind leading the blind. I've added it to my to-do list now either way.
I've never even heard of it, LOL, although it sounds interesting. I think doing a basic newbie guide is a great idea-then just build off of it as time allows.


I get that you can just reverse engineer other games for features, but for beginners, other people's scripts/folders/games are pretty daunting. The advantage to 79flavors creating a guide in one place is so we can see examples clearly, and I can also see it as a great place for experts like Rich and Anne-onymous to weigh in, and hopefully learn some 'best practices', instead of 'well, that...works.." LOL
 

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,961
You're almost certainly right. Problem is I've never done that myself either. I may have a play before finishing the guide and mention it near the end. But I'm hesitant to for two reasons. (1) If I could write a full (simple) game and not know it, then the same is true for the reader - so perhaps can be skipped for a "newbie" guide. (2) I'm not really confident to cover a topic I too don't actually know. It would feel like the blind leading the blind. I've added it to my to-do list now either way.
You might be right on this. I understand most people don't even think on the possibility that there are people out there that would like to play these games in their own language. As English is the "lingua franca" (at least at this forum) even non-native English speakers devs try to release (and even create) their games in English so not many people care about translators like me ;-). There's no market for other languages (except Russian, maybe)

One thing I don't understand of Ren'py is that all the UI coding is ready to be translated (every displayable text is written inside that _(" ") thing) and dialogues are automatically generated as translatable strings, which is nice. But then I think guides and tutorials don't explain that character's names are not translatable by default, and that's very frustrating because almost no dev uses the translation symbols _(" ") when defining his characters. First names aren't usually translated (although some languages with non-occidental symbols might need to do it) but common nouns as "Boy", "Girl", "Unknown", "Mechanic", "Landlady" (lol) and so on should be translated. So if we want a full translation we need to edit the original scripts, and sometimes that's a real pain in you know where