ask For String
Ask the player for a string value.
game.askForString("")
The player is prompted to input a string. Your message is displayed and the player chooses from character selections below it to make a response. Each character of the response string is selected with the A button. You can limit the number of characters the player can type in the response.
The player selects OK and presses the A button to finish typing the response. The response string is then returned to your program.
Parameters
- message: a string that is the prompt message to ask for a response.
- answerLength: the number of characters you want let the player enter. The maximum you can set is
24
and the default is12
.
Returns
- a string value that is the response typed by the player.
Example
Ask the player for a unlock code to continue playing the game.
let unlock = "98745"
if (game.askForString("unlock code:", 5) != unlock) {
game.over()
}