multiple 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
bluedragon77
Newbie
Posts: 13
Joined: Sun May 17, 2015 7:46 pm
Contact:

multiple script files?

#1 Post by bluedragon77 »

Is it possible to put the script into multiple files? And how? Because if I don't do that my script file will be pure chaos. I am only 200+ lines in and I already have several levels of indentation. Also it is very important to transfer some variables between them.

I was thinking of something like this:
-The game starts in the original script files,then depending on the players choices it goes to other ones. And the final return statement is also in the original one.

But could you show me just a hello world example of how to enter another script file,transfer variables between them and then go back to the original one?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: multiple script files?

#2 Post by trooper6 »

Renpy treats all .rpy files as if they were one big file. All the variables are shared. You don't have to do anything special.

In other words this:

script.rpy

Code: Select all

default name = "Jane"

label start:
    call jane_01
    "The game is over"

label jane_01:
    "The name is [name]"
    return

is the same as this:

script.rpy

Code: Select all

default name = "Jane"

label start:
    call jane_01
    "The game is over"
jane.rpy

Code: Select all

label jane_01:
    "The name is [name]"
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

bluedragon77
Newbie
Posts: 13
Joined: Sun May 17, 2015 7:46 pm
Contact:

Re: multiple script files?

#3 Post by bluedragon77 »

cool...but I must make a label and call it.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: multiple script files?

#4 Post by trooper6 »

Call or Jump
This is all explained here: http://www.renpy.org/doc/html/label.html
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: multiple script files?

#5 Post by Onishion »

Yeah, it all depends on how you want to break it up. I leave script.rpy for all my "core" stuff, like initializing variables, starting the story, function elements that get used by the whole thing, and then I have separate files for individual story chunks, individual game mechanics, things like that. If I start working on one file and notice that a subsection is getting way too long, I just copy and rename the file, delete out that section from the original, and delete out everything else from the copy.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]