Possible to name screen with variable?

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
eath
Newbie
Posts: 10
Joined: Tue Jul 14, 2020 11:52 am
Contact:

Possible to name screen with variable?

#1 Post by eath » Thu Jul 16, 2020 8:51 am

Is there a way to loop through a list and define screens like screen item01, screen item02, screen item03...?

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Possible to name screen with variable?

#2 Post by rames44 » Thu Jul 16, 2020 12:30 pm

AFAIK, no. But you can have a single screen alter its contents based on the value of variables...

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Possible to name screen with variable?

#3 Post by Alex » Thu Jul 16, 2020 1:38 pm


User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: Possible to name screen with variable?

#4 Post by hell_oh_world » Thu Jul 16, 2020 3:11 pm

Just use the use and transclude method in screens. Its well documented in the screen language docs. It lets you recycle screens like what you're trying to do considering that item01 and item02 are pretty much the same but only differs in the contents such as item name etc.

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

Re: Possible to name screen with variable?

#5 Post by Imperf3kt » Thu Jul 16, 2020 3:55 pm

You could always use keyword arguments

screen item(item_number):
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

eath
Newbie
Posts: 10
Joined: Tue Jul 14, 2020 11:52 am
Contact:

Re: Possible to name screen with variable?

#6 Post by eath » Tue Jul 21, 2020 12:18 pm

Alex wrote:
Thu Jul 16, 2020 1:38 pm
Kind of sample - viewtopic.php?f=8&t=57095#p520418
This is super cool and interesting! I'll definitely use this for parts of my game. Thanks!

eath
Newbie
Posts: 10
Joined: Tue Jul 14, 2020 11:52 am
Contact:

Re: Possible to name screen with variable?

#7 Post by eath » Tue Jul 21, 2020 12:20 pm

hell_oh_world wrote:
Thu Jul 16, 2020 3:11 pm
Just use the use and transclude method in screens. Its well documented in the screen language docs. It lets you recycle screens like what you're trying to do considering that item01 and item02 are pretty much the same but only differs in the contents such as item name etc.
AH! It's useful to find out about this function. I'll definitely use this in some parts of my game too. Thanks!

Post Reply

Who is online

Users browsing this forum: CharlieFuu69, Google [Bot]