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

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: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

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

#1 Post by Offworlder » Sat Feb 09, 2019 6:31 am

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
Last edited by Offworlder on Sat Feb 09, 2019 10:17 am, edited 1 time in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 611
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: renpy.input: Display a character's name, to simulate dialogue?

#2 Post by Per K Grok » Sat Feb 09, 2019 7:18 am

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

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

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

#3 Post by Offworlder » Sat Feb 09, 2019 7:39 am

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.

User avatar
IrinaLazareva
Veteran
Posts: 372
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: IKG
Location: St.Petersburg, Russia
Contact:

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

#4 Post by IrinaLazareva » Sat Feb 09, 2019 8:24 am

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
There is a light at the end of the tunnel, just pray it's not a train.
___
TODO: unresolved/нерешённое

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

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

#5 Post by Offworlder » Sat Feb 09, 2019 8:58 am

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.

User avatar
IrinaLazareva
Veteran
Posts: 372
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: IKG
Location: St.Petersburg, Russia
Contact:

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

#6 Post by IrinaLazareva » Sat Feb 09, 2019 9:12 am

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
There is a light at the end of the tunnel, just pray it's not a train.
___
TODO: unresolved/нерешённое

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

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

#7 Post by Offworlder » Sat Feb 09, 2019 10:16 am

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!

Post Reply

Who is online

Users browsing this forum: No registered users