Page 1 of 2
How do you organize your scripts
Posted: Fri Mar 29, 2013 6:28 am
by Sabotage
I am a total newbie when in comes to Ren'py (I've just started a few days ago). It's a fantastic engine and I find myself enjoying the scripting; which is a rare case since I was never the "programmer" type. I guess that is testament to how easy it is to use the program!
For my scripting, I tend to just slap on all the commands in one file. I am aware of "calling" separate scripts and I've tried it. I am just curious how advanced users organize their scripts. Any tips or tricks up your sleeve?
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 7:30 am
by Obscura
I'm far from an "advanced" user, but I do have something that generally looks like this:
variable.rpy (for setting and defining all the variables)
main.rpy (for the main storyline)
a .rpy per sprite (the sprites are made up of multiple, interchangeable layers so their code is quite long)
minor_endings.rpy
When the main script starts splitting into different paths, I end up making a new .rpy file for each major path.
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 11:27 am
by TrickWithAKnife
I have different .rpys for different things to make searching easier. Apart from the regular files that everyone has, these are most of what I use mine for at the moment:
- Backgrounds
- Character definitions
- Character images
- Dev notes
- Effects
- Info on various countries
- Intro
- Smartphone
- Test functions
- Variables
Then more for actual dialogue and such, organised into chunks of time. Early on they are organised in days, but further will probably be organised into weeks.
There is some extra language functionality that I've been working on in what little free time I've had recently. That will add at least a few more too.
As you can imagine, the ability for jEdit to line up script files to the side of the window is extremely useful for readability purposes.
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 12:39 pm
by Sabotage
Obscura wrote:I'm far from an "advanced" user, but I do have something that generally looks like this:
variable.rpy (for setting and defining all the variables)
main.rpy (for the main storyline)
a .rpy per sprite (the sprites are made up of multiple, interchangeable layers so their code is quite long)
minor_endings.rpy
When the main script starts splitting into different paths, I end up making a new .rpy file for each major path.
That's good insight, mate! Esp. about the one where you separate the minor endings. Good touch. I'm a bit curious about the "a" file though (the sprite one). I haven't gone as far as scripting the sprite itself. I just go:
img character happy
show character happy
TrickWithAKnife wrote:
I have different .rpys for different things to make searching easier. Apart from the regular files that everyone has, these are most of what I use mine for at the moment:
Backgrounds
Character definitions
Character images
Dev notes
Effects
Info on various countries
Intro
Smartphone
Test functions
Variables
Then more for actual dialogue and such, organised into chunks of time. Early on they are organised in days, but further will probably be organised into weeks.
Oh goodness.. so you can have a separate rpy for the backgrounds and the character images? Wow!
Also on the Smartphone one.. Is that one where you bundle the game for smartphone, or a sort of disclaimer in case they're playing it on smartphone?
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 1:21 pm
by Obscura
a .rpy per sprite (the sprites are made up of multiple, interchangeable layers so their code is quite long)
Sorry, "a" should be changed to "one" .rpy file per sprite.
The code I'm using is this one.
http://lemmasoft.renai.us/forums/viewto ... 51&t=15345
Except I have 9 different mouths, 4 different sets of eyes, and five different sets of eyebrows per sprite. (Plus 2 poses and a number of different outfits.)
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 1:47 pm
by Sabotage
Obscura wrote:a .rpy per sprite (the sprites are made up of multiple, interchangeable layers so their code is quite long)
Sorry, "a" should be changed to "one" .rpy file per sprite.
The code I'm using is this one.
http://lemmasoft.renai.us/forums/viewto ... 51&t=15345
Except I have 9 different mouths, 4 different sets of eyes, and five different sets of eyebrows per sprite. (Plus 2 poses and a number of different outfits.)
That's really helpful. And actually logical, when you think about it (saving file size for one thing). It wouldn't look weird, would it? (Mouth out of place etc. otherwise, this might really be worth picking up). I'll post more specific questions over there (it might be off topic here haha).
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 7:10 pm
by TrickWithAKnife
Sabotage wrote:Oh goodness.. so you can have a separate rpy for the backgrounds and the character images? Wow!
I doubt most people would have a separate .rpy for backgrounds, but I just found it easier to keep things organised like that.
Sabotage wrote:Also on the Smartphone one.. Is that one where you bundle the game for smartphone, or a sort of disclaimer in case they're playing it on smartphone?
Neither. One of the features inside the game is a smartphone that the protagonists can use to do various things.
There's a lot of different functions, with some rather lengthy code, so it really needed its own .rpy.
At the end of the day, it's up to you how many .rpys you have, and what you use them for.
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 10:50 pm
by arachni42
Sabotage wrote:
For my scripting, I tend to just slap on all the commands in one file. I am aware of "calling" separate scripts and I've tried it. I am just curious how advanced users organize their scripts. Any tips or tricks up your sleeve?
I would imagine you'll figure out what works best for you in time. I'm a beginner at Ren'Py, but I've done a lot of other kinds of programming, so I came in with strong preferences for the way I wanted to organize things. "Call" was one of the first things I learned.
My first project has an introduction, then a story for each of five characters in a certain sequence. So it's been pretty simple: introduction.rpy, char1.rpy, char2.rpy, etc. I also made a separate file defining all of the flags. Generally speaking, I like to keep things "modular," so that I'm not crossing over between files all of the time to find stuff. My character definitions are in script.rpy, but that's because there aren't very many of them, and they're all organized together at the top. script.rpy is relatively short, so it's really easy for me to see the overall structure of my game right there. For testing, I can also quickly comment out huge pieces of the game (by commenting out calls) and easily restore them.
I also never, ever, EVER ever give anything a name shorter than 3 characters (and even 3 is pushing it). That is because Ctrl-F is my best friend that I take everywhere I go, and it's pretty tedious to Ctrl-F a variable in 1000s of lines of code if it's named something like "t" or "it".
That's just how I do it; I'd be interested in knowing if other people do keep everything in script.rpy.
Re: How do you organize your scripts
Posted: Fri Mar 29, 2013 11:55 pm
by Ran08
I sort of have a lot of .rpy files because I have one for the main path and I have separate files for each separate route. I also have a different .rpy file for the backgrounds, the images, and even the character definitions themselves. Just to keep things tidy.
And... I can't slap commands into one file. They make my head spin!

Like arachni42, I also just "call" out the different paths, and I have a separate file for the flags.

Re: How do you organize your scripts
Posted: Sat Mar 30, 2013 5:37 am
by ebi brain
Ususally my scripts are just one big file in which I dump EVERYTHING.
It's really chaotic working like that...
So I think after having read this thread,I'm going to split it up in different files...
But I was just wondering, how exactly do you name files?
For instance: day1.rpy, characters.rpy, backgrounds.rpy etc?
Last night I tried to save a file as day1.rpy but I got some traceback error :/
Edit: wait.. I got it! When I use "save as",while you can give the file a different name, it'll just make a copy... so you end up having 2 x "label start"!
Now to find out how to just rename a file:/
Re: How do you organize your scripts
Posted: Sat Mar 30, 2013 6:03 am
by TrickWithAKnife
Close your editor, open your game folder, and rename the files the old-fashioned way. Be aware there may be three copies of everything.
Re: How do you organize your scripts
Posted: Sat Mar 30, 2013 10:13 am
by ebi brain
It's that easy?
So, if I want to rename script.rpy to backgrounds.rpy, all I have to do is rename those three files that are called script.(rpy or something else) in the game directory.
I can do that

Thanks!
Re: How do you organize your scripts
Posted: Sun Mar 31, 2013 7:36 pm
by Kokoro Hane
I've been using Ren'Py since late 2011, and yet, the funny thing is I don't organize my scripts XD I literally just have my whole VN in the one original script file. It can be frustrating to find, admittedly, but I've gotten so used to it it isn't even all that hard anymore. I guess I'm just a messy programmer. Probably my most MESSY coded VN is my first one that I am still writing....oh my gosh, 57,000+ words, breaking into lots of different paths, and I have the labels everywhere. My newer WIPs, even though everything is in one script, I tend to have all related labels one after the other, so generally I know where what paths I am writing are, unlike my first one which has labels just...everywhere, not always corresponding, but no one would notice in the game since it is commanded to jump to where it needs to go XD Most likely, I will begin to organize from now on when I decide to transition my first VN from 6.12.1 to 6.15.2
Re: How do you organize your scripts
Posted: Tue Apr 02, 2013 12:41 am
by Gear
It took me a while to decide how to organize my scripts, but I ended up keeping all the variables, image definitions, character definitions, and startup codes in script.rpy. Then I created Prologue.rpy for all my prologues, 01.rpy for Chapter 1, 02.rpy for all my Chapter 2's, and so-on. I make sure to place all the titles of my chapters in the label and in comments with two hashes so I can CTRL+F them when I need a certain chapter.
Code: Select all
Example: 02.rpy
##Misplaced
label misplaced:
D "Dialogue? Yes! Yay!"
The tutorial has its own file, sometimes if one of the chapters is particularly troublesome with code (I have one that's sort of a branch nexus based on decisions) it'll warrant its own file. But basically, this is the system that worked best for me.
Re: How do you organize your scripts
Posted: Tue Apr 02, 2013 2:35 am
by Audria
OMGosh, that sounds awesome. Like other newbs, I've just been mashing everything into my script.rpy file. How do you do a call to go to another script when needed? Is there a tutorial on that? If so, would someone post a link so I can investigate this?
Thanks for this awesome organizational skills topic!