Input prompt
Explains how to prompt the player for input in Pixi'VN, including usage, retrieval, and removal of input requests.
UI screen
You can find an example of the input prompt dialog UI in the interface examples section.
In visual novels, you may need to ask the player to enter text, numbers, dates, or other values.
Pixi’VN provides functions to handle input prompts. The developer can require the player to enter a value (the game will not continue until a value is provided), while the UI is responsible for displaying the prompt.
Request
To prompt the player for input, use the narration.requestInput()
function.
This function has the following parameters:
props
: An object with input prompt properties:type
(Optional): The type of input prompt (string).
defaultValue
(Optional): The default value to display in the input field.
import { narration, newLabel } from "@drincs/pixi-vn";
export const startLabel = newLabel("start_label", [
() => {
narration.dialogue = "Hello";
},
() => {
narration.dialogue = "What is your name?";
narration.requestInput({ type: "string" });
},
() => {
narration.dialogue = `My name is ${narration.inputValue}`;
},
() => {
narration.dialogue = "How old are you?";
narration.requestInput({ type: "number" }, 18);
},
() => {
narration.dialogue = `I am ${narration.inputValue} years old`;
},
() => {
narration.dialogue = "Describe who you are:";
narration.requestInput({ type: "html textarea" });
},
() => {
narration.dialogue = `${narration.inputValue}`;
},
() => {
narration.dialogue = "Restart";
},
]);
Get
To get input prompt information, use:
narration.isRequiredInput
: Returnstrue
if the player must enter a value.narration.inputType
: Returns the type of input prompt requested.
if (narration.isRequiredInput) {
openInputModal(narration.inputType)
}
Remove
To remove the input prompt request, use narration.removeInputRequest()
.
narration.removeInputRequest()