[SOLVED] Have player input specific text?

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
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

[SOLVED] Have player input specific text?

#1 Post by Offworlder »

I'm trying to figure out how to display a text input box, and require the player to enter specific text in order to continue.
I did find this page in the Ren'py documentation: https://www.renpy.org/doc/html/input.html

I've been playing around with the code there, but I don't quite understand how it works.
Any and all help would be greatly appreciated!
Last edited by Offworlder on Fri Jan 04, 2019 9:38 am, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Have player input specific text?

#2 Post by Alex »

Try

Code: Select all

label start:
    "...under the keyboard I found a piece of yellow paper..."
    label password_check:
        "I took the note."
        "Damn, I barely can read this chicken scratch - '1q2w3e4r5t' or something..."
        $ res = renpy.input("Enter password:")
        if res != "1q2w3e4r5t":
            jump password_check
    "That worked!"

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Have player input specific text?

#3 Post by Offworlder »

Alex wrote: Thu Jan 03, 2019 11:42 am
Thank you so much! Your suggestion is mostly working perfectly, but I did encounter one issue. I wanted new text to display if the input is wrong, and I managed to get that working correctly. However, if the player enters the correct answer the second time around instead of the first, it skips a line of dialogue that's supposed to occur and just jumps straight to the new label.

To clarify, it goes something like this:

What's the password?
CORRECT ANSWER
I think it's working!
JUMP TO NEW LABEL

What's the password?
WRONG ANSWER
Hmm, I don't think that worked. Let's try something else!
CORRECT ANSWER
JUMP TO NEW LABEL

If that makes sense. x_x
Here's my actual code:

Code: Select all

$ res = renpy.input("\"Do you think you can find a spell to get some light in here?\"")
        if res != "123":
            jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (2.0)
    "\"I think it's working!\""
    jump light

label wrongspell1:

"\"Okay! I'm gonna try it out!\""
play sound "sfx/failspell.ogg"
$ renpy.pause (2.0)
"\Uh...I don't think that was right. Maybe we can try something else?\""

$ res = renpy.input("What spell should I try this time?")
if res != "123":
    jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (2.0)
    "\"I think it's working!\""
    jump light
    
label light:
scene bedroom
show vhappy
play music "music/fireplace.ogg"
with flash

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Have player input specific text?

#4 Post by Alex »

Hmm, this code should work, but check the indentation

Code: Select all

label start:
    "..."
    $ res = renpy.input("\"Do you think you can find a spell to get some light in here?\"")
    if res != "123":
        jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (2.0)
    "\"I think it's working!\""
    jump light

label wrongspell1:

    "\"Okay! I'm gonna try it out!\""
    play sound "sfx/failspell.ogg"
    $ renpy.pause (2.0)
    "\Uh...I don't think that was right. Maybe we can try something else?\""

    $ res = renpy.input("What spell should I try this time?")
    if res != "123":
        jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (2.0)
    "\"I think it's working!\""
    jump light
    
label light:
    play music "music/fireplace.ogg"
    scene bedroom
    show vhappy
    with flash
    "?"

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Have player input specific text?

#5 Post by Offworlder »

YES! Apparently, all that I needed to do was change the indentation. xD;;
I apologize for the novice mistake, but thanks a ton for helping out!

Post Reply

Who is online

Users browsing this forum: No registered users