Seperating text into script files?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Kazegen
Newbie
Posts: 13
Joined: Wed Mar 09, 2011 12:18 am
Contact:

Seperating text into script files?

#1 Post by Kazegen »

I'm compiling a demo to release for my game soon, but I'd like to separate my GIGANTIC script for the game into separate script files. A good example of this would be in the tutorial file, where if you look at the game script there's a bunch of tabs at the top for each tutorial. It seems to me like separating the parts of my game into small chunks would make it easier to edit. Is this a practical thing to do, and if so, how would I go about doing it?

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Seperating text into script files?

#2 Post by HigurashiKira »

Simply copy/paste parts of the script into new .rpy files. You can easily jump between scripts with no problems

Code: Select all

label start:
"Blahblahblah"

jump text2:

#This next part is in a seperate .rpy file

label text2:
"Randon stuff"

jump text3:

#Another jump

label text3:
"Yay"
I have moved to a new account. Please contact me here from now on. T/Y~

bink
Regular
Posts: 49
Joined: Sat Jul 09, 2011 4:34 pm
Contact:

Re: Seperating text into script files?

#3 Post by bink »

It's really something you should do to keep your project under control. It makes finding and editing things much easier.
If you want some code to be in a different file, just create a new .rpy file and paste the code in. However, you can't have one half of a function or a label in one file and another half in the other file. You can only copy over passage that can work no matter where they are in the script.
For example, if you have two labels, just copy one over to the new file and delete it from the old file. Jumps between labels will work across multiple files. That's the easiest way to split up your code.

Code: Select all

#in day_one.rpy
label day_one_end:
    "Wow, what a day."
    "I should go to bed now."
    jump day_two_wake_up

#in day_two.rpy
label day_two_wake_up:
    "It's morning already?!"
This works fine. Ren'Py just jumps to a label that is located in another file. As you can see, it's actually quite simple and works automatically. If your story is already divided up into several labels, you can just copy them over.

Kazegen
Newbie
Posts: 13
Joined: Wed Mar 09, 2011 12:18 am
Contact:

Re: Seperating text into script files?

#4 Post by Kazegen »

Ok, worked out fine. Thanks for the help.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]