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: 18
Joined: Sat May 23, 2020 8:08 pm
Projects: Working title to do with string theory. Got any got string puns/phrases? Please do tell me, lol.
Location: Under your bed
Contact:

Linking to other script files?

#1 Post by ForeverAScone » Mon May 25, 2020 12:06 am

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 :)
Your average noob here. Howdydoo

User avatar
isobellesophia
Miko-Class Veteran
Posts: 976
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 » Mon May 25, 2020 12:18 am

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: 2987
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Linking to other script files?

#3 Post by Imperf3kt » 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
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

User avatar
isobellesophia
Miko-Class Veteran
Posts: 976
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 » Mon May 25, 2020 12:33 am

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: 18
Joined: Sat May 23, 2020 8:08 pm
Projects: Working title to do with string theory. Got any got string puns/phrases? Please do tell me, lol.
Location: Under your bed
Contact:

Re: Linking to other script files?

#5 Post by ForeverAScone » Tue May 26, 2020 2:20 pm

Ahh, gotcha. Thanks for the replies :)
Your average noob here. Howdydoo

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

Re: Linking to other script files?

#6 Post by Trafagal » Tue May 26, 2020 9:10 pm

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

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

Re: Linking to other script files?

#7 Post by Imperf3kt » Tue May 26, 2020 10:22 pm

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.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

User avatar
rayminator
Veteran
Posts: 441
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Linking to other script files?

#8 Post by rayminator » Tue May 26, 2020 10:23 pm

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."
when I try to help someone I point them into 2 direction what's right and wrong so they can learn how to

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

Re: Linking to other script files?

#9 Post by Trafagal » Wed May 27, 2020 12:13 am

Thank you both! Those are very useful information~!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot], neo-naughtager