Character say a following when player inputs characters names.

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
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Character say a following when player inputs characters names.

#1 Post by isobellesophia »

Hi,

As i said in the title above how can i do that?

I have my input code.

Code: Select all

  f "Oh! i forgot your name, what was it again?"
    
    screen input(prompt):
        window at truecenter:   
            xmaximum 500
            background Image("gui/nameinput.png")  
            vbox:
                xalign 0.5
                yalign 0.5
                text prompt style "input_prompt"
                input id "input"
            
    python:
      name = renpy.input("What is your name?")

      name = name.strip() or "Human"
      
    show f happy 1 with dissolve
    f "Oh yeah! it's [name], right?"
For example, the player types "Fina", and when after he inputs that, the real "Fina" character will say a thing, and let the player to choose again, vice versa for all character names.

Code: Select all

f "Whoops! That is my name, how about something else?
Thanks.
I am a friendly user, please respect and have a good day.


Image

Image


strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Character say a following when player inputs characters names.

#2 Post by strayerror »

This should do what you're looking for. It uses a sub-label (notice the label name starts with a dot) to jump back to the prompt each time the user enters the disallowed name.

Code: Select all

label getting_to_know_you:
    f "Oh! i forgot your name, what was it again?"
    label .prompt_for_name:
    $ name = renpy.input("What is your name?").strip() or "Human"
    if name == f.name: # could hard code the name if you prefer using: name == "Fina"
        f "Whoops! That is my name, how about something else?"
        jump .prompt_for_name
    show f happy 1 with dissolve
    f "Oh yeah! it's [name], right?"
    return

lacticacid
Regular
Posts: 36
Joined: Fri Nov 23, 2018 6:44 pm
Contact:

Re: Character say a following when player inputs characters names.

#3 Post by lacticacid »

Code: Select all

jump choosename
label choosename:
    python:
      name = renpy.input("What is your name?")

      name = name.strip() or "Human"

    if name=="Fina":
        f "Whoops! That is my name, how about something else?"
        jump choosename
    else:
        f "Oh yeah! it's [name], right?"
Something like this. Putting this under a label will allow the game to return there after the wrong name choice and, well, "if-else" statements are self-explanatory.
; )
~There is almost always a better, easier way to approach a problem.~

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Character say a following when player inputs characters names.

#4 Post by isobellesophia »

Thank you guys! Its working like a charm!
I am a friendly user, please respect and have a good day.


Image

Image


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

Re: Character say a following when player inputs characters names.

#5 Post by Imperf3kt »

This could be extended to include a python list, and check if multiple names are used.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Andredron