[SOLVED] Help with Customizing renpy.input

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
daisy
Newbie
Posts: 6
Joined: Thu Mar 07, 2019 12:42 am
Contact:

[SOLVED] Help with Customizing renpy.input

#1 Post by daisy »

I'm making a short project that frequently utilizes renpy.input. I'd very much like to have the text (both prompt and response) centered in the screen and with a custom background (like a textbox) when the player is inputting text, as to differentiate it from general dialogue from characters.

Is there anyone who would happen to know how to go about making these customization? I'm stumped.
Last edited by daisy on Mon Jun 17, 2019 4:46 pm, edited 1 time in total.

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: Help with Customizing renpy.input

#2 Post by Per K Grok »

daisy wrote: Sat Jun 15, 2019 1:00 am I'm making a short project that frequently utilizes renpy.input. I'd very much like to have the text (both prompt and response) centered in the screen and with a custom background (like a textbox) when the player is inputting text, as to differentiate it from general dialogue from characters.

Is there anyone who would happen to know how to go about making these customization? I'm stumped.
You can put an input function in a screen as shown in the code example below. You can place the screen where you want and customize it as you want.
The text entered by the user will in this case be stored in the variable 'firstname'.

You can then use 'firstname' to trigger the response that could also be given in your own customized screen.

Code: Select all

init python:
    def name_func(newstring):
        store.firstname = newstring

default firstname = ""


screen inputScr():
    zorder 50
    fixed:
        xpos 200
        ypos 340
        text "Input the name of your kin and press Enter" color "#000" font "DejaVuSans.ttf" size 12
        input color "#000" pos(0, 25) length 15  changed name_func size 30
        

daisy
Newbie
Posts: 6
Joined: Thu Mar 07, 2019 12:42 am
Contact:

Re: Help with Customizing renpy.input

#3 Post by daisy »

Pressing enter to progress doesn't seem to work. Furthermore, is there a way to include different prompts in the screen without having to make multiple screens with different prompts? Here's an example of what I've been prototyping thus far, for reference on what I mean:
(I've only started seriously coding very recently, so apologies if it's a little janky)

Code: Select all

#This simply formats the input so it can be processed.
init python:
    def codewordFix():
        global codeword;
        codeword = codeword.strip();
        codeword = codeword.lower();

label start:
    python:
        codeword = renpy.input("What will you do?")
    $codewordFix()
    jump codewordProcessing

label codewordProcessing:
    if codeword == "speak":
        jump speakProcessing
    elif codeword == "look":
        jump lookProcessing
    else:
        "Invalid action"
    jump start
    
 label speakProcessing:
    python:
        codeword = renpy.input("To whom will you speak to?")
    $codewordFix()
    if codeword == "guy" or "boy" or "man":
        jump guyProcessing
    elif codeword == "girl" or "woman" or "gal":
        jump girlProcessing
    else:
        "Invalid action"
    jump speakProcessing
    
 label guyProcessing:
    python:
        codeword = renpy.input("What will you say to him?")
    $codewordFix()
    if codeword == "food":
        g "Food is good."
        "That was unhelpful..."
    elif codeword == "dogs":
        g "Dogs are good"
    else:
        "Invalid action."
        jump guyProcessing
    jump start
    

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Help with Customizing renpy.input

#4 Post by philat »

If you want a text adventure, might be easier to work with something like Inform or TADS...

Anyway, you can just customize the input screen. For instance, assuming you're using the default input screen, adding the following moves the input window to the center and makes it a 600x300 light gray box.

Code: Select all

style input_window:
    background Solid("#ccc")
    xsize 600
    ysize 300
    xalign 0.5
    yalign 0.5
See the documents Styles / Screens and Screen Language for more. https://www.renpy.org/doc/html/#customizing-ren-py

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: Help with Customizing renpy.input

#5 Post by Per K Grok »

daisy wrote: Sun Jun 16, 2019 6:05 pm Pressing enter to progress doesn't seem to work. Furthermore, is there a way to include different prompts in the screen without having to make multiple screens with different prompts?

---
My code only stored the input from the player in the variable. Nothing will happen until you use the variable. Below an example on how you could do this with the actions in your code example.

Code: Select all

init python:
    def codewordFix():
        global codeword;
        codeword = codeword.strip();
        codeword = codeword.lower();

    def name_func(newstring):
        store.codeword = newstring

default codeword= ""
default question=1

screen inputScr():
    if question==1:
        text "What will you do?"
    else:
        text "something else"

    input color "#000" pos(0, 25) length 15  changed name_func


label start:
    show screen inputScr
    pause
    $ codewordFix()
    if codeword == "speak":
        $ question=2
        jump speakProcessing
    elif codeword == "look":
        $ question=3
        jump lookProcessing
    else:
        "[codeword]"
        "Invalid action"
    hide screen inputScr
    jump start

Though if this is what you want to use the input for you probably do just as well with the dialog input that you already has used.

Also, if you only have a small number of acceptable answers you might consider using a menu (choice) model instead.

daisy
Newbie
Posts: 6
Joined: Thu Mar 07, 2019 12:42 am
Contact:

Re: Help with Customizing renpy.input

#6 Post by daisy »

Ah, this is exactly what I've been looking for! Thank you so much! :D

And in the future, there will be way more than just a handful of options. The few that I used were just for testing purposes. :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot]