With some limitations, Ren'Py can prompt the user to input a small
amount of text. This prompting is done by the renpy.input()
function,
which returns the entered text, allowing it to be saved in a variable
or otherwise processed.
On Linux, text input is limited to languages that do not require input method (IME) support. Most Western languages should work, but Chinese, Japanese, and Korean probably won't.
The renpy.input function is defined as:
renpy.
input
(prompt, default=u'', allow=None, exclude=u'{}', length=None, with_none=None, pixel_width=None, screen=u'input', mask=None, copypaste=True, **kwargs) linkCalling this function pops up a window asking the player to enter some text. It returns the entered text.
input
screen is used.If config.disable_input
is True, this function only returns
default.
Keywords prefixed with show_
have the prefix stripped and
are passed to the screen.
Due to limitations in supporting libraries, on Android and the web platform this function is limited to alphabetic characters.
Games that use renpy.input will often want to process the result further, using standard Python string manipulation functions. For example, the following will ask the player for his or her name and remove leading or trailing whitespace. If the name is empty, it will be replaced by a default name. Finally, it is displayed to the user.
define pov = Character("[povname]")
python:
povname = renpy.input("What is your name?", length=32)
povname = povname.strip()
if not povname:
povname = "Pat Smith"
pov "My name is [povname]!"
In this, the length of the input is limited to 32 characters. It's important to test your game with long names, to makes sure that those names do not break text layout. At the same time, too short fields may prevent people from entering their preferred name.