Rename the M.C. in the preferences 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
tcassat
Regular
Posts: 30
Joined: Tue Oct 03, 2017 7:32 pm
Contact:

Rename the M.C. in the preferences menu?

#1 Post by tcassat » 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.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 628
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
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

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

#2 Post by Per K Grok » Wed Feb 12, 2020 2:17 pm

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.
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

Post Reply

Who is online

Users browsing this forum: Kiyo