Page 1 of 1

[SOLVED] renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 6:31 am
by Offworlder
I actually tried to figure this out a while back, but I never came upon a working solution!
Basically, my current game relies heavily on inputting text at various points. It's supposed to appear as though MC is asking questions, and PLAYER must type in their answer to continue. I've gotten as far as having the input text display at the same speed as regular dialogue, along with having quotation marks around it. It's nearly perfect, but I can't seem to figure out how to have MC's name appear above the input text, as it would for standard dialogue.

It kind of ruins the effect I'm going for when MC's name disappears every time the player gets to an input screen. I would very much appreciate some assistance with figuring this out!

Here's what I've got so far:

Code: Select all

    label firstspell:
        $ res = renpy.input( Text( _('"Just...let me know if you find anything, okay?"'), slow_cps=40.0) ).strip()
        if res == "":
            jump firstspell1
        elif res != "123":
            jump wrongspell1
        if res == "123":
            jump gjob

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 7:18 am
by Per K Grok
Offworlder wrote: Sat Feb 09, 2019 6:31 am
---
but I can't seem to figure out how to have MC's name appear above the input text, as it would for standard dialogue.

It kind of ruins the effect I'm going for when MC's name disappears every time the player gets to an input screen. I would very much appreciate some assistance with figuring this out!

Here's what I've got so far:

Code: Select all

    label firstspell:
        $ res = renpy.input( Text( _('"Just...let me know if you find anything, okay?"'), slow_cps=40.0) ).strip()
        if res == "":
            jump firstspell1
        elif res != "123":
            jump wrongspell1
        if res == "123":
            jump gjob
I'm not sure if this is what you are looking for, but you could use a screen, something like that.

Code: Select all

 
 screen name(namn):
    text namn xpos 130 ypos 370 color "#00F"
 

(Position, color and what have you, adjusted to what you need.)

Code: Select all

 
label firstspell:
    show screen name("John")
    $ res = renpy.input( Text( _('"Just...let me know if you find anything, okay?"'), slow_cps=40.0) ).strip()
    if res == "":
        hide screen name
        jump firstspell1
    elif res != "123":
        hide screen name
        jump wrongspell1
    if res == "123":
        hide screen name
        jump gjob
 

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 7:39 am
by Offworlder
Per K Grok wrote: Sat Feb 09, 2019 7:18 am I'm not sure if this is what you are looking for, but you could use a screen, something like that.

Code: Select all

 
 screen name(namn):
    text namn xpos 130 ypos 370 color "#00F"
 

(Position, color and what have you, adjusted to what you need.)

Code: Select all

 
label firstspell:
    show screen name("John")
    $ res = renpy.input( Text( _('"Just...let me know if you find anything, okay?"'), slow_cps=40.0) ).strip()
    if res == "":
        hide screen name
        jump firstspell1
    elif res != "123":
        hide screen name
        jump wrongspell1
    if res == "123":
        hide screen name
        jump gjob
 
Thanks for the quick reply!
I tried out your code, and it seems to be at least close to what I'm going for. I discovered one major issue while playing around with the positioning, though. The name screen goes behind the text box, rather than sitting on top of it like MC's name should.

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 8:24 am
by IrinaLazareva
another option: rewrite the input() screen:

Code: Select all

default whoinput = None

screen input(prompt, who=whoinput):
    style_prefix "input"
    window:
####<<
        if who is not None:
            window:
                style "namebox"
                text who size gui.name_text_size
####<<        
        vbox:
            xalign gui.dialogue_text_xalign
            xpos gui.dialogue_xpos
            xsize gui.dialogue_width
            ypos gui.dialogue_ypos
            text prompt style "input_prompt"
            input id "input"
$ whoinput variable controls the name of the person asking the question through input().You're gonna have to change it manually. For example:

Code: Select all

define qw = Character('MC')
label start:
    qw 'Start'
    $ whoinput = 'MC'
    $ res = renpy.input( Text( _("Just...let me know if you find anything, okay?"), slow_cps=40.0)).strip()
...
P.S. if whoinput=None, the input() will work in a standard way

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 8:58 am
by Offworlder
IrinaLazareva wrote: Sat Feb 09, 2019 8:24 am another option: rewrite the input() screen:
That does exactly what I'm looking for!
...Unfortunately, it doesn't seem to work in combination with another addition to the input screen I already had in place. x_x

Here's the full code:

Code: Select all

default whoinput = None

screen input(prompt, who=whoinput):
    style_prefix "input"
    window:

        if who is not None:
            window:
                style "namebox"
                text who size gui.name_text_size

        vbox:
            xalign gui.dialogue_text_xalign
            xpos gui.dialogue_xpos
            xsize gui.dialogue_width
            ypos gui.dialogue_ypos
            text prompt style "input_prompt"
            input id "input"


transform blink_tr():
    alpha 1.5
    linear 1.1 alpha 0.3
    linear 1.1 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:

                input id "input"
                text ">" at blink_tr 
                input id "input"

style input_prompt is default

style input_prompt:
    xalign gui.dialogue_text_xalign
    properties gui.text_properties("input_prompt")

style input:
    xalign gui.dialogue_text_xalign
    xmaximum gui.dialogue_width
There's a blinking icon below the input dialogue to alert PLAYER they'll need to enter something. If I put your code above the icon code, MC's name doesn't appear. If I put it below the icon code, MC's name appears, but the icon does not.

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 9:12 am
by IrinaLazareva

Code: Select all

default whoinput = None
            
transform blink_tr():
    alpha 1.5
    linear 1.1 alpha 0.3
    linear 1.1 alpha 1.0
    repeat

screen input(prompt, who=whoinput):
    style_prefix "input"
    window:
        if who is not None:
            window:
                style "namebox"
                text who size gui.name_text_size
        vbox:
            xalign gui.dialogue_text_xalign
            xpos gui.dialogue_xpos
            xsize gui.dialogue_width
            ypos gui.dialogue_ypos

            text prompt style "input_prompt"
            hbox:

                input id "input"
                text ">" at blink_tr 
                input id "input"

style input_prompt is default

style input_prompt:
    xalign gui.dialogue_text_xalign
    properties gui.text_properties("input_prompt")

style input:
    xalign gui.dialogue_text_xalign
    xmaximum gui.dialogue_width

Re: renpy.input: Display a character's name, to simulate dialogue?

Posted: Sat Feb 09, 2019 10:16 am
by Offworlder
IrinaLazareva wrote: Sat Feb 09, 2019 9:12 am
YES! That is completely perfect! You just solved something that's been plaguing me for ages. xD
Thank you so much for your help!