Where do I put variables? Multiple .rpy 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
Anarchy
Veteran
Posts: 331
Joined: Mon Sep 12, 2011 1:51 am
Projects: Fairy Tales of Innocent Children
Contact:

Where do I put variables? Multiple .rpy files?

#1 Post by Anarchy »

I'm a little bit confused on where we're supposed to put our variables. Should they go before the start label, or inside the start label? Because once I put all my variables before the start label, and somewhere down the line the game spit back "variable not defined" at me, even though it had already been defined at the beginning. So I moved all my variables to inside the start label instead, which solved the problem, but then the problem was that when I started the game from a load later on in the script, the game skipped the start label and all the variables inside it, meaning that I encountered the "variable not defined" problem again.

Also, can I get some general information/advice on how to script in multiple .rpy files? I've only ever used one .rpy file before, so I don't know if I have to define my variables and characters in every single .rpy file? Or can I leave all my variables and characters and assets in one .rpy file, and break down my script into multiple .rpy files? Any general tips on how to organize a really, really long script with tons of menus/variables?

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Where do I put variables? Multiple .rpy files?

#2 Post by SundownKid »

Anarchy wrote:So I moved all my variables to inside the start label instead, which solved the problem, but then the problem was that when I started the game from a load later on in the script, the game skipped the start label and all the variables inside it, meaning that I encountered the "variable not defined" problem again.
You will have to restart the game and make those saves again in order to make the variables work correctly.
Anarchy wrote:Also, can I get some general information/advice on how to script in multiple .rpy files? I've only ever used one .rpy file before, so I don't know if I have to define my variables and characters in every single .rpy file? Or can I leave all my variables and characters and assets in one .rpy file, and break down my script into multiple .rpy files? Any general tips on how to organize a really, really long script with tons of menus/variables?
Each .rpy file acts as if they were all one big file. So, you can break apart your script, images, transforms, etc. over multiple files with no difference than if it were all in one large one. In fact, that's basically necessary for any medium-to-long length visual novel.

You can organize it by days in the script, scenes, chronologically or by location, et cetera.

User avatar
Hiddlestoners
Regular
Posts: 126
Joined: Sun Jul 01, 2012 9:27 am
Completed: Thinking Of You [KN]
Projects: PERPLEXITY [Mystery VN], simplicity [KN,Fluff,GxB,BxG]
Contact:

Re: Where do I put variables? Multiple .rpy files?

#3 Post by Hiddlestoners »

Anarchy wrote:Should they go before the start label, or inside the start label?
For me I've always gone before the start label and used an init before typing in what my variables are. Seems to work for me.
ENOSHIMA BOWL!
Image

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]