Page 1 of 1

renpy.input boxed in center of the screen?

Posted: Sun Aug 04, 2013 3:10 pm
by Kokoro Hane
When using renpy.input so the user can enter in their own name for the MC, is there a way to have that appear as its own textbox in the center of the screen with words above it (example; "What is your name?") instead of in the dialogue textbox? (As well as hide the dialogue textbox during this part)

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 6:02 am
by tigersmurf
Sure. If I understand you correctly, why not just create a screen (a background) that features the words you want? Use your background image for the current scene and your favorite photo editor, and then save it to your game folder and define it...


Code: Select all

image name = "what's your name.png"
and then...

Code: Select all

scene name with dissolve
Or anything like that.

That's the simplest way. You could also create an imagemap or imagebutton at the center of the screen that, when clicked, gives the user a chance to type in their character's name. http://lemmasoft.renai.us/forums/viewto ... f=8&t=9812

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 6:04 am
by tigersmurf
Although, I may have misunderstood you. Did you mean you wanted them to be able to type in their name at the center? Sorry, I think I interpreted it as you just wanted the question "what's your name" to appear in the center. Oops.

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 7:05 am
by Levrex
Why, sure. Just edit the input screen as you'd do normally and don't forget to change the style.

The following code:

Code: Select all

screen input:

    window:

        style "nvl_window"
        
        text prompt xalign 0.5 yalign 0.4
        input id "input" xalign 0.5 yalign 0.5

    use quick_menu
produces the result you can see in an attached image.

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 1:52 pm
by xavimat
I was looking for this, also. Thanks, Levrex.

Is there a way to show the question without deleting the former text? I mean, that's the usual behavior of the nvl mode, if you don't "nvl clear" it, it doesn't disappear. But with this modified input screen, the former text disappears.

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 4:31 pm
by Kokoro Hane
Thank you so much! I'll definitely be trying that!

Re: renpy.input boxed in center of the screen?

Posted: Mon Aug 05, 2013 5:52 pm
by Levrex
xavimat wrote:Is there a way to show the question without deleting the former text?
http://www.renpy.org/wiki/renpy/doc/ref ... s/ui.input

Either that or:

1) Add modal True and zorder 1 lines to the input screen.
2) Call the screen with $ x = renpy.call_screen("input", prompt="Whatcha gonna do?") instead of $ x = renpy.input("Whatcha gonna do?").

Re: renpy.input boxed in center of the screen?

Posted: Tue Aug 06, 2013 4:42 am
by xavimat
Levrex wrote:
xavimat wrote:Is there a way to show the question without deleting the former text?
1) Add modal True and zorder 1 lines to the input screen.
2) Call the screen with $ x = renpy.call_screen("input", prompt="Whatcha gonna do?") instead of $ x = renpy.input("Whatcha gonna do?").
Thanks, Levrex. I've used your modificatins and it's working. I can't use, though, the "deafult" parameter of the input. It's that possible?

Re: renpy.input boxed in center of the screen?

Posted: Tue Aug 06, 2013 11:07 am
by Levrex
Doesn't seem like so, because those functions understand "default" parameter differently.

You can, however, check if the returned string is an empty one and, if that's the case, i.e. if the user does not input anything, assign it a "standard" value. The user won't see it when the screen appears, though, but you can still write in the prompt string that «if you leave the string empty, you will be referred to as John Doe».

Re: renpy.input boxed in center of the screen?

Posted: Tue Aug 06, 2013 11:37 am
by DragoonHP
xavimat: Modify your imput screen

Code: Select all


screen input(prompt, someText = ""):

    window style "input_window":
        has vbox

        text prompt style "input_prompt"
        input id "input" style "input_text" default someText

Then call your screen like this: $ x = renpy.call_screen("input", prompt="Whatcha gonna do?", someText = "Something")

Re: renpy.input boxed in center of the screen?

Posted: Wed Aug 07, 2013 5:49 am
by xavimat
DragoonHP wrote:xavimat: Modify your imput screen

Code: Select all


screen input(prompt, someText = ""):

    window style "input_window":
        has vbox

        text prompt style "input_prompt"
        input id "input" style "input_text" default someText

Then call your screen like this: $ x = renpy.call_screen("input", prompt="Whatcha gonna do?", someText = "Something")
Thanks, DragoonHP. It's working!

Re: renpy.input boxed in center of the screen?

Posted: Sun Feb 25, 2018 8:48 am
by MilywayObree
Umm... if you would want it to be in a frame, you would want to do this...
This example is what i used for a mod, the game is a game I made that I call "Roll":

Code: Select all

screen guess_input(roll_action, roll_act):
    modal True

    zorder 200

    style_prefix "confirm"

    add "gui/overlay/confirm.png"
    key "K_RETURN" action [Play("sound", gui.activate_sound)]

    frame:

        vbox:
            xalign .5
            yalign .5
            spacing 30

            label _("What will be your guess?"):
                style "confirm_prompt"
                xalign 0.5

            input default "None" value VariableInputValue("guess2") length 1 allow "012345"

            hbox:
                xalign 0.5
                spacing 100

                textbutton _("Guess!") action [ roll_action, roll_act, Hide("guess_input"), Show("guessed") ]
now you would want to define the variable..

Code: Select all

default persistent.guess = ""
default guess2 = persistent.guess
default roll2 = None
init python:
    def FinishGuess():
        persistent.guess = guess2
and now this....

Code: Select all

call screen guess_input(roll_action=Function(FinishGuess), roll_act=SetVariable("roll2", (random.randint(1,5))))

e "you guessed the number [guess2], let's see if it is correct!"

menu:
    "Roll":
        show text("You rolled the number [roll2]")

if roll2 == 1:
     if guess2 == 1:
        e "you guessed the correct number!"
        call win
    else:
        e "sorry, you guessed the wrong number!"
        call tryagain
and so on.....

Re: renpy.input boxed in center of the screen?

Posted: Sun Dec 12, 2021 3:14 pm
by EternalVoid
I have tried this because I wanted to make an nvl visual novel, but I can't seem to put the input thing on top of the nvl thing. Maybe if I delete image of the nvl background?

I don't want to do that though, so help on this would be welcome.