Page 1 of 1

Rename the M.C. in the preferences menu?

Posted: Wed Feb 12, 2020 12:05 am
by tcassat
Hello!

At the beginning of my game, the player has the option to rename the main character according to this code:

Code: Select all

    menu .name:
        "Your current name is [mc]."

        "Change name":
            $ mc = renpy.input("What's your name? (2-10 characters)", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
            $ mc = mc.strip()
            if len(mc) < 2:
                "You must name your character a minimum of 2 letters."
                $ mc = "Robert"
                jump .name
            $ mc = mc.title()
            $ persistent.mc = mc
            jump .name

        "Continue":
            pass
However, I also want to give the player the option to enter the preferences menu and be able to change the name directly there. How could I do that?

I added some custom vboxes to my preferences menu, but they follow the "radio" style and are only used to set some variables. I have no idea how I can create a vbox there where the player can input text or something...

Thanks.

Re: Rename the M.C. in the preferences menu?

Posted: Wed Feb 12, 2020 2:17 pm
by Per K Grok
tcassat wrote:
Wed Feb 12, 2020 12:05 am
Hello!

At the beginning of my game, the player has the option to rename the main character according to this code:

Code: Select all

    menu .name:
        "Your current name is [mc]."

        "Change name":
            $ mc = renpy.input("What's your name? (2-10 characters)", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
            $ mc = mc.strip()
            if len(mc) < 2:
                "You must name your character a minimum of 2 letters."
                $ mc = "Robert"
                jump .name
            $ mc = mc.title()
            $ persistent.mc = mc
            jump .name

        "Continue":
            pass
However, I also want to give the player the option to enter the preferences menu and be able to change the name directly there. How could I do that?

I added some custom vboxes to my preferences menu, but they follow the "radio" style and are only used to set some variables. I have no idea how I can create a vbox there where the player can input text or something...

Thanks.
This should work.

Code: Select all


vbox:
    label _("MC name")
    text "Name: [mc]"
    input changed name_func
    textbutton _("Change name") action ShowMenu('preferences')

you also need this function

Code: Select all

init python:
    def name_func(newstring):
        store.mc = newstring

and having
mc defined.