[Solved]Calling a label/screen from 2 different 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
Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

[Solved]Calling a label/screen from 2 different files

#1 Post by Doeny »

I have a question. Let's say there's a situation where I create all my labels and screens in one file. Can I affect/edit one of those in another file? Like if I share m game, can I just share one additional file that changes content from the 1st one, or do I have to repost the whole game once again. I wanna know it because I'm considering future changes that are way to small to reupload the whole project, so It'd be cool if there was an option to just throw another, smaller file.
Last edited by Doeny on Sat Nov 26, 2022 12:47 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Calling a label/screen from 2 different files

#2 Post by Ocelot »

From the game point of view there are no individual files. Game behase as if all files were pasted together in one large script.

If you structure your game right to accept additional data and change its behavior based on that, you can do it.

For example, in this thread I posted an example of game you can update episodically. You can add new episodes, labels and unlock conditions in other files when nessesary.
viewtopic.php?f=8&t=61970
< < insert Rick Cook quote here > >

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Calling a label/screen from 2 different files

#3 Post by Doeny »

Ocelot wrote: Sat Nov 26, 2022 10:54 am From the game point of view there are no individual files. Game behase as if all files were pasted together in one large script.

If you structure your game right to accept additional data and change its behavior based on that, you can do it.

For example, in this thread I posted an example of game you can update episodically. You can add new episodes, labels and unlock conditions in other files when nessesary.
viewtopic.php?f=8&t=61970
That's not exacly what I was looking for. For example, is there a way to "add" an imagebutton to already existing screen by adding another file to the game folder? Like is there a line of code that would allow me to change screen properties after the screen is once created? If I'm not saying things clear enought (which I'm probably not) I'll hand a lteral example.

Here's an example code from original game file:

Code: Select all

screen home():
	imagebutton:
		focus_mask True
		idle "door_1"
		action Jump("room_1")
	imagebutton:
		focus_mask True
		idle "door_2"
		action Jump("room_2")
	imagebutton:
		focus_mask True
		idle "door_3"
		action Jump("room_3")
Now, I wanna have 3 different files here, each unlocking another door. But let's say I wanna add only one door at the same time but still have the ability to choose each door by swapping the files. Is there a way to create a code that will "add" a single door to already existing screen, or do I have to copy the whole thing throught and add some conditionals? Or in short, is there a way to update already existing game content without changing the original code? I'll mark that I really wanna make it in 3 different files for storage and performance reasons, as the original game is already at its limit.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Calling a label/screen from 2 different files

#4 Post by Ocelot »

If you originally make your screen in a way that allows further additions (by dynamically creating buttons following description in some list, for example, like in my by-chapter game), you can control that. If not, you cannot.

Alternatively, you can simply replace a single file containing that screen with updated version if you want, leaving rest of files alone.

From perfomance reasons there is no difference betwee one script file and hundred files, since they are loaded together as one single huge file, only organisation reasons.
< < insert Rick Cook quote here > >

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Calling a label/screen from 2 different files

#5 Post by Doeny »

Ocelot wrote: Sat Nov 26, 2022 12:39 pm If you originally make your screen in a way that allows further additions (by dynamically creating buttons following description in some list, for example, like in my by-chapter game), you can control that. If not, you cannot.

Alternatively, you can simply replace a single file containing that screen with updated version if you want, leaving rest of files alone.

From perfomance reasons there is no difference betwee one script file and hundred files, since they are loaded together as one single huge file, only organisation reasons.
Alrighty, thankies.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], piinkpuddiin