Use a Text Input BoxTip Make sure you are familiar with using variables before reading this tutorial – it will make life much easier!
Many visual novels allow players to input text and then use that input in the game somehow. For example, asking for a player’s name, or having the player answer quizzes. You can also add this type of feature to your games in TyranoBuilder.
Let’s look at how to have a game ask for the player’s name.
First, we define a variable to store the player’s input.
From the menu at the top of the TyranoBuilder window, select Program > Variables, and add a variable called ‘name’.
Now, from the Tools Area at the left, drag and drop an ‘Input Box’ component into the Scene Editor.
In the ‘Assigned Variable’ field of the Input Box parameters, enter the variable ‘name’ and click on the Positioning Tool to position the new Input Box.
Now any text that is input into this box by the player will be stored in the variable ‘name’.
But, we need one more step to store the text in the variable: the ‘Commit Input’ component must run for the game to store the text in the variable ‘name’.
The text input function can be completed by the following setup:
Components much be placed in the above order. Here is a summary:
① Input Box: to receive the user input
② Image Button: to accept the text (Branch Button will not work)
③ Stop component: to await the user input
④ Label: this should be the target of the above Image Button
⑤ Commit Input component: to store the text in the assigned variable
⑥ Page break component: to remove the Input box from the screen
⑦ TyranoScript can be used to easily include the text in sentences.
That pretty much covers it! There are a few steps to using input from the player, but it’s actually straightforward and you’ll probably get the hang of it after trying it just once.
Go ahead and preview the game we created above.
Now you know how to process input from your players!
Using Play Input to Branch the Story
Because the inputted text is stored in a variable, we can use it in a conditional jump to branch the story.
So let’s have a look at how to repeat the input in case nothing is input.
Lay out the components as below:
The main points here are:
・Place a’get_input’ (or however you choose to name it) Label before the Input Box component
・After the Commit Input component, check the input value and proceed if it is not blank.
・If the game does not jump, it means that the player did not enter anything, so it display ‘Name, please!’ and returned to the get_input label.
This is how you prevent the game from proceeding if the player did not input any text.
Here endeth the tutorial!