Is it possible to make a "variable" screen?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Is it possible to make a "variable" screen?

#1 Post by Nanahs »

In my game you can choose between 3 different characters: Mary, Janet and Claire.
Since they have different styles, I want them to have different bedrooms.

So in the begining of the game, a choice menu would open for you to choose between them.

The problem is that each bedroom has imagebuttons placed in different places (according to the decoration).

So I wanted to have something like: "screen marybedroom", "screen janetbedroom", "screen clairebedroom".

And according to the character you chose, the correct bedroom would appear when the scene is in the bedroom.

But I have no idea how or if it's possible. Or if I could make something with the "if, elif, else".

Sometimes I still get confused about the codes that "work together".

Does anyone has any idea on how I could do this? What would be a better way to do it?

Thanks.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Is it possible to make a "variable" screen?

#2 Post by Per K Grok »

Nanahs wrote: Sat Dec 08, 2018 8:20 am In my game you can choose between 3 different characters: Mary, Janet and Claire.
Since they have different styles, I want them to have different bedrooms.

So in the begining of the game, a choice menu would open for you to choose between them.

The problem is that each bedroom has imagebuttons placed in different places (according to the decoration).

So I wanted to have something like: "screen marybedroom", "screen janetbedroom", "screen clairebedroom".

And according to the character you chose, the correct bedroom would appear when the scene is in the bedroom.

But I have no idea how or if it's possible. Or if I could make something with the "if, elif, else".

Sometimes I still get confused about the codes that "work together".

Does anyone has any idea on how I could do this? What would be a better way to do it?

Thanks.
You could have different lines of scripts for each character. You could even have them as separate documents.

script_mary.rpy
script_janete.rpy
and
script_claire.rpy.

You could start of in script.rpy
with a menu to chose which character to play

Code: Select all

label start:
    menu:
        "What character will you play?"
            "Mary":
                jump maryStart
            "Janete":
                jump janeteStart
            "Claire":
                jump clairStart
If you do it this way you don't have to worry about having to constantly having fixes for which of the characters the player has chosen. Just make sure you do not duplicate the label names. So you cannot have i.e. 'label bedroom' in more than one of the scripts. You could do something like 'label bedroom_m', 'label bedroom_j' and 'label bedroom_c' to keep it simple.

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to make a "variable" screen?

#3 Post by Nanahs »

Per K Grok wrote: Sat Dec 08, 2018 9:21 am
Nanahs wrote: Sat Dec 08, 2018 8:20 am In my game you can choose between 3 different characters: Mary, Janet and Claire.
Since they have different styles, I want them to have different bedrooms.

So in the begining of the game, a choice menu would open for you to choose between them.

The problem is that each bedroom has imagebuttons placed in different places (according to the decoration).

So I wanted to have something like: "screen marybedroom", "screen janetbedroom", "screen clairebedroom".

And according to the character you chose, the correct bedroom would appear when the scene is in the bedroom.

But I have no idea how or if it's possible. Or if I could make something with the "if, elif, else".

Sometimes I still get confused about the codes that "work together".

Does anyone has any idea on how I could do this? What would be a better way to do it?

Thanks.
You could have different lines of scripts for each character. You could even have them as separate documents.

script_mary.rpy
script_janete.rpy
and
script_claire.rpy.

You could start of in script.rpy
with a menu to chose which character to play

Code: Select all

label start:
    menu:
        "What character will you play?"
            "Mary":
                jump maryStart
            "Janete":
                jump janeteStart
            "Claire":
                jump clairStart
If you do it this way you don't have to worry about having to constantly having fixes for which of the characters the player has chosen. Just make sure you do not duplicate the label names. So you cannot have i.e. 'label bedroom' in more than one of the scripts. You could do something like 'label bedroom_m', 'label bedroom_j' and 'label bedroom_c' to keep it simple.
Hello! I'll try to do it. Thank you so much! :)

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Is it possible to make a "variable" screen?

#4 Post by IrinaLazareva »

Code: Select all

screen bedroom(hero = 'default'):
    if hero== 'Mary':
        text 'something_about_Mary'
        # add, style, buttons and etc....
        
    elif hero=='Janet':
        text 'something_about_Janet'

    elif hero=='Claire':
        text 'something_about_Claire'        
        
    else:
        text 'default'    

label start:
    menu:
        'Mary':
            show screen bedroom('Mary')
        'Janet':
            show screen bedroom('Janet')
        'Claire':
            show screen bedroom('Claire')
        'None':
            show screen bedroom
    '!'

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to make a "variable" screen?

#5 Post by Nanahs »

IrinaLazareva wrote: Sat Dec 08, 2018 1:01 pm

Code: Select all

screen bedroom(hero = 'default'):
    if hero== 'Mary':
        text 'something_about_Mary'
        # add, style, buttons and etc....
        
    elif hero=='Janet':
        text 'something_about_Janet'

    elif hero=='Claire':
        text 'something_about_Claire'        
        
    else:
        text 'default'    

label start:
    menu:
        'Mary':
            show screen bedroom('Mary')
        'Janet':
            show screen bedroom('Janet')
        'Claire':
            show screen bedroom('Claire')
        'None':
            show screen bedroom
    '!'
Thank you so much! I'll try this code too :)

Post Reply

Who is online

Users browsing this forum: No registered users