new day, new questions about renpy

Niteowl

Member
Game Developer
Apr 6, 2018
298
379
So, I have a couple general questions for you guys.....

1- First of all a general question
a renpy script actually has several scripts.... the main one,. the GUI scripts and Screen scripts

I understand the main game or whatever goes into the main one, after the label 'start'..... info about screens in the screns page etc
question
What do we have to put in the main one, and what can we put in new screens?
I mean, is it okay to define variables in a new page or do they have to be at the beginning of the page with the main story?

I was thinking it would be easier to organize stuff if we can use different pages (documents) for various parts advice on this topic? Or sources of information?
Could you guys give me a general idea of how best to organize stuff (using different pages if possible)

2- I would like to implement a stats system in my game.... stats for girls etc
anyways, I understand how to do that, and even how to make screens to show those stats....
but I would like to add some bars/meters to show the current stats values in a stats page

my question is...any good source of info on adding some bar or meters? I had a look at some online tutorials but they're not too clear
what's the best way to add something like that (generally speaking)?

specifically, I had in mind a system where you have opposite emotions at each end of the bar, so the level would show a girl's tendency.....

I mean, let's say, for example, I want to have a stat called "Eileen's confidence" (just something I made up now as an example, I have my list somewhere else)
so the opposites would be
Shy Outgoing
and in between I'd like to show a bar (and, although more complex, it would be nice if it could change colors based on how close to each end it is....like maybe blue for below 30, green between 30 and 70, and red between 70 and 100

I think it's a bit complex....but yeah, any advice? Any good tutorials you know of to figure out something like that?

Is the three color system even possible?

any advice would be greatly appreciated
 

wurg

Active Member
Modder
Apr 19, 2018
705
1,655
As far as where to put the things you want in the scripts, you can put it anywhere, all in one file or in 100 different files, it's up to you. They separate them out in the beginning just to categorize the basics for you to make them easier to find. There are only a couple of rules how to start and end the game, label start and the final return statement, the rest is up in the air, do whatever makes the most sense for you when you code. I segregate everything in different files according to what they do. Just my way.

Al far as the bar and meters, I'm sure you could do it, but I have no experience with it, best advice is to find a game where someone has done something similar and figure out how they did it and modify it to what you want it to do. It's how I learned most of the stuff I have.
 
  • Like
Reactions: Niteowl and Brasdf

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
2- I would like to implement a stats system in my game.... stats for girls etc
anyways, I understand how to do that, and even how to make screens to show those stats....
but I would like to add some bars/meters to show the current stats values in a stats page
Then look at games that use it for their stats. There's many of them doing it, not always in the same way. By example Super Powered use the screen statement, while Summertime Saga use a build bar in a really different way.
 

Niteowl

Member
Game Developer
Apr 6, 2018
298
379
As far as where to put the things you want in the scripts, you can put it anywhere, all in one file or in 100 different files, it's up to you. They separate them out in the beginning just to categorize the basics for you to make them easier to find. There are only a couple of rules how to start and end the game, label start and the final return statement, the rest is up in the air, do whatever makes the most sense for you when you code. I segregate everything in different files according to what they do. Just my way.

Al far as the bar and meters, I'm sure you could do it, but I have no experience with it, best advice is to find a game where someone has done something similar and figure out how they did it and modify it to what you want it to do. It's how I learned most of the stuff I have.

ok, thanks, this is helpful.....

so, just to be clear, I can use as many files as I want and there is a lot of flexibility.....
but how about the main script? shouldn't that be in one file? If you break that up, how do you connect it to other files? BY using the label function? Like jump to another file, the story continues etc.....

Start and return need to be in the same file right? Or not?

sorry, just figuring out the basics
 

Niteowl

Member
Game Developer
Apr 6, 2018
298
379
Then look at games that use it for their stats. There's many of them doing it, not always in the same way. By example Super Powered use the screen statement, while Summertime Saga use a build bar in a really different way.
ok fair enough, I will.....
but I don't play a lot of games (and recently I'm too busy trying to make my own to even play my favorites) so not always sure where to look.
Also, I had a look at some games and they have a lot of stuff already, it's hard to figure out where anything is (unless you know how it's all organized, like if you made the game)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
Also, I had a look at some games and they have a lot of stuff already, it's hard to figure out where anything is (unless you know how it's all organized, like if you made the game)
If you want to make a game yourself, you'll have to familiarize yourself with all this anyway. So it will be killing two birds with one stone.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
so, just to be clear, I can use as many files as I want and there is a lot of flexibility.....
but how about the main script? shouldn't that be in one file? If you break that up, how do you connect it to other files? BY using the label function? Like jump to another file, the story continues etc.....
The "main" script file is just a file. While the RenPy launcher tends to create a script.rpy, screen.rpy, options.rpy, etc... those names are entirely arbitrary and I guess intended to help introduce RenPy to new devs.
You could for example rename script.rpy to be wibble.rpy and things would still work just fine. (remember to delete any other script.* files, like script.rpc if you do try doing this).

99% of devs will still keep a script.rpy file as their starting point. Some will write the whole game within that single file. Others will split things up into something like chapter01.rpy, chapter02.rpy, script2.rpy, script3.rpy, intro.rpy, bedroom.rpy, jennifer.rpy or any other filename that makes sense to you as the developer when splitting up the source into separate chunks (files).

However, what RenPy is looking for is a label start:. Wherever that line is, whatever file it is within... is the starting point of the game. If you do something like a jump intro, label intro: could be within any file too. Again, I would guess most devs would either leave it within the script.rpy or put it somewhere like intro.rpy.

Some devs will tell you that splitting things up is being organized. Some devs will tell you the opposite. Just do whatever feels right for you. Don't overthink it. Don't try to be clever for clever's sake. If you aren't sure... just write one huge long script.rpy file for your first game. Then when it comes time to write your second game... then think about whether splitting things up might make sense... now you have a bit more insight.


Start and return need to be in the same file right? Or not?
You mentioned return. That would usually be the last line of code executed, as it returns control back to the main menu of the game. Again, it could be in any file. Exactly where will depend on the type of game you're writing. A (mostly) linear game will likely have an "end", even if you are writing chapters/version each release - in that case, you're likely to have a "Thanks for playing my game... check back next month for more updates. Please visit my Patreon/Subscribstar page". Your return would go after that.
For a sandbox game, you might not even need one. I guess it depends on your game.


sorry, just figuring out the basics
Me too... me too.
 
  • Like
Reactions: Niteowl

Niteowl

Member
Game Developer
Apr 6, 2018
298
379
The "main" script file is just a file. While the RenPy launcher tends to create a script.rpy, screen.rpy, options.rpy, etc... those names are entirely arbitrary and I guess intended to help introduce RenPy to new devs.
You could for example rename script.rpy to be wibble.rpy and things would still work just fine. (remember to delete any other script.* files, like script.rpc if you do try doing this).

99% of devs will still keep a script.rpy file as their starting point. Some will write the whole game within that single file. Others will split things up into something like chapter01.rpy, chapter02.rpy, script2.rpy, script3.rpy, intro.rpy, bedroom.rpy, jennifer.rpy or any other filename that makes sense to you as the developer when splitting up the source into separate chunks (files).

However, what RenPy is looking for is a label start:. Wherever that line is, whatever file it is within... is the starting point of the game. If you do something like a jump intro, label intro: could be within any file too. Again, I would guess most devs would either leave it within the script.rpy or put it somewhere like intro.rpy.

Some devs will tell you that splitting things up is being organized. Some devs will tell you the opposite. Just do whatever feels right for you. Don't overthink it. Don't try to be clever for clever's sake. If you aren't sure... just write one huge long script.rpy file for your first game. Then when it comes time to write your second game... then think about whether splitting things up might make sense... now you have a bit more insight.




You mentioned return. That would usually be the last line of code executed, as it returns control back to the main menu of the game. Again, it could be in any file. Exactly where will depend on the type of game you're writing. A (mostly) linear game will likely have an "end", even if you are writing chapters/version each release - in that case, you're likely to have a "Thanks for playing my game... check back next month for more updates. Please visit my Patreon/Subscribstar page". Your return would go after that.
For a sandbox game, you might not even need one. I guess it depends on your game.




Me too... me too.

Thanks a lot for the long reply man, it's really very helpful and makes perfect sense.
Actually, I'm glad this is the case because I would definitely like to split the files so it's easier to keep track of where everything is.... I only have like two days of my game and the script already looks too bulky to be easily manageable once I add more

However, there is one point I'm, noobishly perhaps, still a little unclear on

The way I understand it, in Renpy the game starts from the 'start' label, as you also said. Now, you said the label 'return' can be anywhere'....good to know.....Still, Renpy is essentially linear. Of course we can split the path into various ones etc but the fundamental logic is fairly linear......
so, all I'm saying is, ok, we can do anything we want....but I'm guessing that when we want to move from one renpy sciprt to another one we need to use a jump command to jump to a label in another script, right? otherwise Renpy might not know where to go once it gets to the last line of the first script.
Or is there something I'm not aware of?
 

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
Now, you said the label 'return' can be anywhere'....good to know....
After a while with all the jumping, skipping, pole vaulting, the return to end the game will return you somewhere else in the game. If this happens use this to end the game.
Python:
$ MainMenu(confirm=False)()
 
  • Like
Reactions: Niteowl

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
It's important first of all that you are clear about how you plan to split scripts from the beginning.

If for example you are making a linial game (VN), you can split the scripts by chapters (or releases).

If, on the other hand, the game is freeroam, since the story and the player interaction are not linial, you can divide the scripts by scenarios, by characters, by maps, or others.

In my game (freeroam) I started without knowing that, but I soon realized that having everything in a script was impossible, the file was getting bigger and bigger and it was very complicated to locate things (having to use the search function every moment).

Now what I do is:
- Scripts for navigation maps: These are important because that's where the player chooses where to go, in what scenario.
- Scripts for each scenario: There may be some text, but basically there are a series of conditional commands that then redirect the player to the right action, depending on the day, time zone, game status, etc...
- Scripts for each character: That's where there's the scene with each character and its corresponding text.

Practical example:
- Map script: Player selects the location of the park; "jump" to the script of the park, which has its label "park".
- When loading the "park" label of the park script there is a conditional, it checks the day and time, and;
-- It could be at night, in this case it jumps to the map script (after showing a message saying you can't go to the park at night).
-- It could be a weekday, so I jump to the tag "park_train" that is inside the same script, and that is so that the player can train running; as soon as the training ends, "jump" towards the map.
--- It could be a weekend in the morning, so the player meets Katia and can train with her, "jump" to the label "park_katia_train" which is in another script called "katia" (at the end of training with Katia, "jump" back to the map.
 
  • Like
Reactions: Niteowl

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
The way I understand it, in Renpy the game starts from the 'start' label, as you also said. Now, you said the label 'return' can be anywhere'.
Yup.
Quick note though: return is a command, not a label.

So it'd look something like this:

Python:
# blah, blah, loads of code.

    jump thanks_for_playing

label thanks_for_playing:

    scene black with dissolve
    "Thanks for playing my game. If you liked it and aren't already a supporter, consider visiting my Patreon page".
    "See you next month".

    return

And as mickydoo says... if you're ever in any doubt... $ MainMenu(confirm=False)() will force a return to the main menu without using return


[...] but I'm guessing that when we want to move from one renpy sciprt to another one we need to use a jump command to jump to a label in another script, right? otherwise Renpy might not know where to go once it gets to the last line of the first script.

Essentially, yes.
Not least, because if your script file just ends - RenPy has no clue which file you might (or might not) want to go to next.

However, it's probably easier if you stop thinking about jumping to other script files. You jump to a label. That label can be anywhere, in any file. The fact you've put label day6_visit_cafe: into a file called day6.rpy is purely an arbitrary choice by you. RenPy doesn't care. All it cares about is that there is a label that matches the jump somewhere.

Using a single script.rpy file means never having to worry about figuring out which file a particular label is stored in. Which is why I suggested it might be a good idea for a first project.

If you do end up choosing to use multiple source files, consider using label names prefixed by the name of the script file that contains them... like my "day6" example. e.g. If you have a script file for "bedroom", consider naming all the labels in that file "label bedroom_blahblah:" or something similar. Or "Jennifer" or "chapter02" or whatever, depending on how you split things up.
 
  • Like
Reactions: Niteowl