[SOLVED] Prevent empty text input/more obvious text input box?

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] Prevent empty text input/more obvious text input box?

#1 Post by Offworlder »

My current game has various instances of PLAYER needing to enter specific text to continue. I'm using a pretty basic "renpy.input" code to accomplish this, but I've realized there are a couple of issues!

First, I want to make sure the player can't enter NO text. There doesn't necessarily need to be a limit, but it wouldn't make sense to leave the box empty. SOLVED! Thank you, ninjaK4T_06.

Second, I'm wondering if there's a way to make it more obvious that PLAYER can enter text. The dialogue that appears when text should be inputted looks exactly the same as standard dialogue, with no indication of the ability to type anything. For immersion/story purposes, I want to avoid direct statements like "Type here!". Some sort of visual cue to show that typing is necessary to proceed would be ideal. Maybe either a separate text box or a blinking icon?

Any and all would be greatly appreciated! I'm completely stuck.

Here's what I've got so far:

Code: Select all

$ res = renpy.input("\"Just...let me know if you find anything, okay?\"")
        if res != "123":
            jump wrongspell1

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

label wrongspell1:

    "\"Is that a spell? Let's give it a shot!\""
    play sound "sfx/failspell.ogg"
    $ renpy.pause (1.5)
    "\Uh...I don't think that was right. Maybe we can try something else?\""

    $ res = renpy.input("I'll be waiting right here! Sorry I can't do more to help.")
    if res != "123":
        jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (1.5)
    "\"I think it's working!\""
    jump light
Last edited by Offworlder on Sun Jan 06, 2019 9:10 am, edited 4 times in total.

ninjaK4T_06
Newbie
Posts: 6
Joined: Fri Nov 30, 2018 6:19 am
Contact:

Re: Prevent empty text input/more obvious text input box?

#2 Post by ninjaK4T_06 »

hmm im not sure about the how to make the input more obvious. maybe theres a way to make the text cursor blink?

but for the empty text, wouldn't this work?

Code: Select all

label something:
    $ res = renpy.input("\"Just...let me know if you find anything, okay?\"")
    if res == "":
        jump something
    elif res != "123":
        jump wrongspell1
that way if the player inputs nothing, it'll just takem back to the input

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
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-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Prevent empty text input/more obvious text input box?

#3 Post by Per K Grok »

Offworlder wrote: Sat Jan 05, 2019 6:54 am My current game has various instances of PLAYER needing to enter specific text to continue. I'm using a pretty basic "renpy.input" code to accomplish this, but I've realized there are a couple of issues!

First, I want to make sure the player can't enter NO text. There doesn't necessarily need to be a limit, but it wouldn't make sense to leave the box empty.

Second, I'm wondering if there's a way to make it more obvious that the player CAN enter text. At the moment, the dialogue looks exactly the same as standard dialogue, with no indication of the ability to type anything. For immersion/story purposes, I want to avoid direct statements like "Type here!". If at all possible, I'd prefer some sort of visual cue that entering text is needed to continue. Maybe a separate text box?

Any and all would be greatly appreciated! I'm completely stuck.

Here's what I've got so far:

Code: Select all

$ res = renpy.input("\"Just...let me know if you find anything, okay?\"")
        if res != "123":
            jump wrongspell1

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

label wrongspell1:

    "\"Is that a spell? Let's give it a shot!\""
    play sound "sfx/failspell.ogg"
    $ renpy.pause (1.5)
    "\Uh...I don't think that was right. Maybe we can try something else?\""

    $ res = renpy.input("I'll be waiting right here! Sorry I can't do more to help.")
    if res != "123":
        jump wrongspell1

    play sound "sfx/success.ogg"
    $ renpy.pause (1.5)
    "\"I think it's working!\""
    jump light
You could try this

Code: Select all

label spell:
    $ res = renpy.input("\"Just...let me know if you find anything, okay?\" {p}{color=#66F} Enter your spell:{/color}").strip()
    if res=="":
        "\"Please enter an input text!\""
        jump spell
    elif res != "123":
        jump wrongspell1
    else:
        play sound "sfx/success.ogg"
        $ renpy.pause (1.5)
        "\"I think it's working!\""
        jump light

label wrongspell1:
    "\"Is that a spell? Let's give it a shot!\""
    play sound "sfx/failspell.ogg"
    $ renpy.pause (1.5)
    "\Uh...I don't think that was right. Maybe we can try something else?\""
    jump spell
It is basically the same thing that ninjaK4T_06 said, but with a little bit extra :)

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

Re: Prevent empty text input/more obvious text input box?

#4 Post by Offworlder »

ninjaK4T_06 wrote: Sat Jan 05, 2019 7:55 am that way if the player inputs nothing, it'll just takem back to the input
Thank you! Your suggestion is exactly what I was looking for!

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

Re: Prevent empty text input/more obvious text input box?

#5 Post by Offworlder »

Per K Grok wrote: Sat Jan 05, 2019 9:45 am It is basically the same thing that ninjaK4T_06 said, but with a little bit extra :)
Having some sort of message pop up to let the player know they need to enter something is a good suggestion, too!
In this particular case, though, I'm trying to simulate the player having a conversation with the MC. If the box is blank, they aren't actually "saying" anything. It seem like it'd break immersion for the MC to still respond in some way.

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

Re: Prevent empty text input/more obvious text input box?

#6 Post by Alex »

Offworlder wrote: Sat Jan 05, 2019 6:54 am Second, I'm wondering if there's a way to make it more obvious that PLAYER can enter text.
You easily can modify the input screen in screens.rpy

Code: Select all

transform blink_tr():
    alpha 1.0
    linear 0.75 alpha 0.3
    linear 0.75 alpha 1.0
    repeat
    
screen input(prompt):
    style_prefix "input"

    window:

        vbox:
            xalign gui.dialogue_text_xalign
            xpos gui.dialogue_xpos
            xsize gui.dialogue_width
            ypos gui.dialogue_ypos

            text prompt style "input_prompt"
            hbox:
                text "---> "
                input id "input"
                text ">" at blink_tr # or you can show a small image instead, like
                #add "my_img.png" at blink_tr
                text " <---"

style input_prompt is default
https://www.renpy.org/doc/html/screens.html#hbox

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

Re: Prevent empty text input/more obvious text input box?

#7 Post by Offworlder »

Alex wrote: Sat Jan 05, 2019 1:36 pm You easily can modify the input screen in screens.rpy
https://www.renpy.org/doc/html/screens.html#hbox
Wow! That's completely perfect and exactly what I was looking for. Thank you!
I do have one additional question. I figured out how to have entered text appear after the blinking icon rather than before it, but now there's a static line after the blinking icon as well:

Image

Do you know how I can remove this?
I just changed the position of "input id" like so:

Code: Select all

text ">" at blink_tr
input id "input"

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

Re: Prevent empty text input/more obvious text input box?

#8 Post by Alex »

Well, actually I don't know - when I changed the code like you did I didn't get any line...
Did you changed the font for the game? Have you tried to show another blinking symbol or letter, or maybe even an image? Maybe add an extra space after >, like "> "...

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
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-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Prevent empty text input/more obvious text input box?

#9 Post by Per K Grok »

Offworlder wrote: Sat Jan 05, 2019 10:18 pm
----
now there's a static line after the blinking icon as well:

Image

Do you know how I can remove this?
That line probably is the marker for the input position for text and if so you should not want to remove it.

If you input text, does the line move along with the text staying at the end of the string? If you have text in the input can you move the line using arrow left and right and then input new text from the new position? Then it is the input position marker.

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

Re: Prevent empty text input/more obvious text input box?

#10 Post by Offworlder »

Per K Grok wrote: Sun Jan 06, 2019 5:42 am That line probably is the marker for the input position for text and if so you should not want to remove it.

If you input text, does the line move along with the text staying at the end of the string? If you have text in the input can you move the line using arrow left and right and then input new text from the new position? Then it is the input position marker.
The line is definitely there for indicating text position, but it's not necessary when there's already a blinking arrow to show where text will be. It takes away from the aesthetics, in my opinion.

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

Re: Prevent empty text input/more obvious text input box?

#11 Post by Offworlder »

Alex wrote: Sun Jan 06, 2019 5:19 am Well, actually I don't know - when I changed the code like you did I didn't get any line...
Did you changed the font for the game? Have you tried to show another blinking symbol or letter, or maybe even an image? Maybe add an extra space after >, like "> "...
I believe the line is supposed to be there as an indicator of where text will appear. What's interesting is that the line was visible in my game when I first started coding, then disappeared at some point while I continued the coding process, then reappeared again when I added your code for the blinking icon. xD

I tried both of your suggestions (adding a space and using an image instead), but the line stubbornly refused to leave. On the bright side, I actually figured out a different way to get rid of it!

Code: Select all

input id "input"
text ">" at blink_tr 
input id "input"
When I originally had "input id" at the top, the line didn't appear but it made text type to the left of the arrow instead of the right. It seems having "input id" at the top AND bottom is the perfect combination of everything I wanted. xDD

Post Reply

Who is online

Users browsing this forum: No registered users