String Functions
sgreig
09 Apr 2012, 21:56Hey there,
I was wondering if some of you more advanced Quest users could help me with some string work. Specifically, I want to be able to evaluate whether or not a player's input contains a specific character, in this case a space.
At the moment, the game asks the player to input two words separated by a space, and if they do everything works fine. But if they don't enter two words separated by a space, either by forgetting to enter a space or accidentally hitting enter before they enter the second word for example, Quest spits out an error message because of the following script that splits the string based on the "space" character. I would prefer this not to happen, but instead prompt the player to retry.
Unfortunately, I don't know how to go about implementing this in Quest, as I can't find any information on the wiki for something that allows me to essentially say:
Help would be greatly appreciated. Thanks!
I was wondering if some of you more advanced Quest users could help me with some string work. Specifically, I want to be able to evaluate whether or not a player's input contains a specific character, in this case a space.
At the moment, the game asks the player to input two words separated by a space, and if they do everything works fine. But if they don't enter two words separated by a space, either by forgetting to enter a space or accidentally hitting enter before they enter the second word for example, Quest spits out an error message because of the following script that splits the string based on the "space" character. I would prefer this not to happen, but instead prompt the player to retry.
Unfortunately, I don't know how to go about implementing this in Quest, as I can't find any information on the wiki for something that allows me to essentially say:
player_input = GetInput()
if (player_input does not contain " ") {
msg ("Please try again")
}
Help would be greatly appreciated. Thanks!
Alex
09 Apr 2012, 22:05sgreig
10 Apr 2012, 01:21That did the trick! Thanks to that, plus an if and a while statement, I now have a working error handler! Yay!