Linking to other 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
User avatar
ForeverAScone
Newbie
Posts: 22
Joined: Sat May 23, 2020 8:08 pm
Location: Under your bed
Contact:

Linking to other script files?

#1 Post by ForeverAScone »

I was just wondering if there was a way to link to seperate script files rather than storing an entire game in one huge script file, so I can split it up chapter by chapter or something more manageable like that. Thank you :)
:D
Artist for hire!! Check out my post with details here!
viewtopic.php?f=61&t=65610
Portfolio here!
https://sprinklebara.crevado.com/artwork

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Linking to other script files?

#2 Post by isobellesophia »

Hello new user, it can be, you can create seperate files by creating a new file like for example.

script.rpy
another.rpy

Just make a new empty file and that's it.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Linking to other script files?

#3 Post by Imperf3kt »

As above, making a new file is all that's needed and is actually recommended for (very slight) performance improvements.

Just be sure to use labels and jumps returns etc correctly, remember that files load alphanumerically, and do not start any file names with 00
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Linking to other script files?

#4 Post by isobellesophia »

00 is for RenPy common files, or also known as the function of the entire script when you create your first game, including all in there such as gui's, save files and etc, it fills with python codes and such.

like this one for example.

00gui.rpy
00common.rpy

Files like this, you should NEVER touch them, unless you know about the specific parts in that script, or you are a expert at python or anything else, or else, it'll break your game and the other games has been created especially, will break it.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
ForeverAScone
Newbie
Posts: 22
Joined: Sat May 23, 2020 8:08 pm
Location: Under your bed
Contact:

Re: Linking to other script files?

#5 Post by ForeverAScone »

Ahh, gotcha. Thanks for the replies :)
:D
Artist for hire!! Check out my post with details here!
viewtopic.php?f=61&t=65610
Portfolio here!
https://sprinklebara.crevado.com/artwork

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Linking to other script files?

#6 Post by Trafagal »

Imperf3kt wrote: Mon May 25, 2020 12:24 am As above, making a new file is all that's needed and is actually recommended for (very slight) performance improvements.

Just be sure to use labels and jumps returns etc correctly, remember that files load alphanumerically, and do not start any file names with 00
Hi,

I'm still quite new to Renpy, just to be sure i understand correctly. It doesn't matter what your file name is (as long as it does not begins with 00) If you initiate "label" or "jump", Renpy will search through the folder for existing .rpy files just to find that "jump"/"label" location, and not searching for the name of that Renpy file where the "label"/"jump" is?

For example:
In script.rpy, you wrote "jump Cafe"
In antherfile.rpy, "Label cafe"

Thank you
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Linking to other script files?

#7 Post by Imperf3kt »

Yes that's correct.
The script of a Ren'Py game is made up of all the files found under the game directory ending with the .rpy extension. Ren'Py will consider each of these files (in Unicode order), and will use the contents of the files as the script.

Generally, there's no difference between a script broken into multiple files, and a script that consists of one big file. Control can be transferred between files by jumping to or calling a label in another file. This makes the division of a script up into files a matter of personal style – some game-makers prefer to have small files (like one per event, or one per day), while others prefer to have one big script.

To speed up loading time, Ren'Py will compile the .rpy files into .rpyc files when it starts up. When a .rpy file is changed, the .rpyc file will be updated when Ren'Py starts up. However, if a .rpyc file exists without a corresponding .rpy file, the .rpyc file will be used. This can lead to problems if a .rpy file is deleted without deleting the .rpyc file.

Filenames must begin with a letter or number, and may not begin with "00", as Ren'Py uses such files for its own purposes.
You can read more about it here
https://www.renpy.org/doc/html/language_basics.html

Pytom has also mentioned a few things about the behaviour throughout the forum, so those are a bit harder to link for you.


Just be aware that if you name a script file something and your script ends without a return, or jump, renpy will continue the script at the next file in unicode order and this might cause issues of you have a label there that isn't supposed to come next.
Last edited by Imperf3kt on Tue May 26, 2020 10:29 pm, edited 2 times in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Linking to other script files?

#8 Post by rayminator »

here is a example

script.rpy

Code: Select all

label start:
    a "Hey Kira lets go to the cafe today."
    k "Okay Rayminator Lets go right now,"
    a "Okay lets go."
    jump cafe

another.rpy

Code: Select all

label cafe:
    a "Okay here we are at the cafe what would you like to get Kira?"
    k "Let's get some coffee and some domuts."
    a "Okay."

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Linking to other script files?

#9 Post by Trafagal »

Thank you both! Those are very useful information~!
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

Post Reply

Who is online

Users browsing this forum: Kocker