MC name change in main menu

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
treoes
Newbie
Posts: 9
Joined: Wed Oct 16, 2019 5:10 am
Contact:

MC name change in main menu

#1 Post by treoes »

Hi. :)

So right the player can choose his MC name in-game, but I got a few requests if they can change it again (later) and want to add this feature to main menu. I saw a few games that offer that.

Can anybody suggest any topic on this? Or a guide? (only a beginner at renpy) :)

Do I use the same code as below? But how do I use it? When a player clicks on the menu where do I send them?

Right now

Code: Select all

    if not persistent.player_name:
        label nameYourCharacter:

        $ player_name = renpy.input("What would you like to be called? If leave this blank, your secret name will be {b}Steven{/b}.")

        $ player_name = player_name.strip()

        if not player_name:
            $ player_name = "Steven"

        $ persistent.player_name = player_name

        "Great! Lets get started, [persistent.player_name]"
        jump afterNaming
    else:
        "Your name is {b}[persistent.player_name]{/b}. Do you want to keep this name?"
        menu:
            "Keep the name {b}[persistent.player_name] ":
                "All will know you as {b}[persistent.player_name]{/b}."
                jump afterNaming
            "Change the name {b}[persistent.player_name]{/b}":
                "Ok, {b}[persistent.player_name]{/b}."
                jump nameYourCharacter

    label afterNaming:
Thanks. :)

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: MC name change in main menu

#2 Post by hell_oh_world »

Code: Select all

label _name_changer:
    $ player_name = renpy.input("What would you like to be called? If leave this blank, your secret name will be {b}Steven{/b}.")

    $ player_name = player_name.strip()

    if not player_name:
        $ player_name = "Steven"

    $ persistent.player_name = player_name

    return

label name_changer:
    if not persistent.player_name:
        call _name_changer
        "Great! Lets get started, [persistent.player_name]"
        
    else:
        "Your name is {b}[persistent.player_name]{/b}. Do you want to keep this name?"
        menu:
            "Keep the name {b}[persistent.player_name] ":
                "All will know you as {b}[persistent.player_name]{/b}."
                
            "Change the name {b}[persistent.player_name]{/b}":
                "Ok, {b}[persistent.player_name]{/b}."
                call _name_changer

    return
You can alter your code and make it look like this, then in the main menu, the button that will trigger the name change, use the action Start("name_changer").
Eg.

Code: Select all

textbutton "Change Name" action Start("name_changer")

treoes
Newbie
Posts: 9
Joined: Wed Oct 16, 2019 5:10 am
Contact:

Re: MC name change in main menu

#3 Post by treoes »

@hell_oh_world worked like a charm. Thanks!

Post Reply

Who is online

Users browsing this forum: simple_human