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.
[SOLVED] Help with Customizing renpy.input
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.
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.
[SOLVED] Help with Customizing renpy.input
Last edited by daisy on Mon Jun 17, 2019 4:46 pm, edited 1 time in total.
- 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
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.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.
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
Re: Help with Customizing renpy.input
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)
(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
Re: Help with Customizing renpy.input
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.
See the documents Styles / Screens and Screen Language for more. https://www.renpy.org/doc/html/#customizing-ren-py
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
- 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
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
Also, if you only have a small number of acceptable answers you might consider using a menu (choice) model instead.
Re: Help with Customizing renpy.input
Ah, this is exactly what I've been looking for! Thank you so much!
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.
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.
Who is online
Users browsing this forum: Bing [Bot]