#number# entered by player as a letter/word instead
steve the gaming guy
11 Aug 2005, 18:29This may be a simply question with a simple answer but what I'm wanting to do is ask a player how old they are.
I first used "Enter next command into string variable" putting the command in #age#.
This does work but I want them to receive a message advising of incorrect entry if they enter a word instead of a number.
Example...
What is your age?
If command = 25, then that would be a correct entry.
If command = twenty-five (or any other word), that would be incorrect.
==========================
Similar scenario
Instead of using "If answer is 'yes'" using the pop up window, I just want a question asked in the main game window where the player answers with yes, y, no, or n. And if any other entry is entered, they should receive a message stating so.
What I tried works part way. I used "Enter next command into string variable" putting the command in #answer#. If #answer# is 'yes' or 'y', then it is a positive answer, if else, it is a negative. Naturally, that would not be the best way because anything other than yes or y would cause the response for "no".
Example...
Do you wish to play?
If command = yes (y, no, or n), that is a correct entry.
If command = anything else, they receive a message politely asking them to answer the question.
I first used "Enter next command into string variable" putting the command in #age#.
This does work but I want them to receive a message advising of incorrect entry if they enter a word instead of a number.
Example...
What is your age?
If command = 25, then that would be a correct entry.
If command = twenty-five (or any other word), that would be incorrect.
==========================
Similar scenario
Instead of using "If answer is 'yes'" using the pop up window, I just want a question asked in the main game window where the player answers with yes, y, no, or n. And if any other entry is entered, they should receive a message stating so.
What I tried works part way. I used "Enter next command into string variable" putting the command in #answer#. If #answer# is 'yes' or 'y', then it is a positive answer, if else, it is a negative. Naturally, that would not be the best way because anything other than yes or y would cause the response for "no".
Example...
Do you wish to play?
If command = yes (y, no, or n), that is a correct entry.
If command = anything else, they receive a message politely asking them to answer the question.
paul_one
11 Aug 2005, 20:40Number one:
Set a numeric like so:
set numeric <%input.number%; #number#>
(don't name them the same... It can be done, but just is confusing and you can't be sure quest can understand it fully..)
Test if the number is above 1... If it isn't then loop back.
Quick example:
You can't be totally sure, but asking for confirmation (Are you SURE your age is %input.number%?) in ANOTHER loop outside of that one, using a flag or something, then you can be reasonably sure.
For the yes/y/no/n. You could either just put another conditional inside the else:
As you see, it'll go in one loop until you enter Y/Yes/N/No.
... I'd personally put it into a function, so you could pass it the conditionals/whatever and recieve an answer or not (1 or 0)...
You could then expand it from Yes/Y/No/N to:
N/North/E/East/W/West/S/South/U/Up/D/Down/C/Crack...
Set a numeric like so:
set numeric <%input.number%; #number#>
(don't name them the same... It can be done, but just is confusing and you can't be sure quest can understand it fully..)
Test if the number is above 1... If it isn't then loop back.
Quick example:
set numeric <input.number; 0>
repeat until ( %input.number% > 1 ) {
msg <Your age?>
enter <input.age>
set numeric <input.number; #input.age#>
}That will keep looping until a number above 1 (or a sentance like '2h4g5') is entered.You can't be totally sure, but asking for confirmation (Are you SURE your age is %input.number%?) in ANOTHER loop outside of that one, using a flag or something, then you can be reasonably sure.
For the yes/y/no/n. You could either just put another conditional inside the else:
set numeric <answer; 0>
repeat while ( %answer% = 0 )
enter <yes.no>
if ( #yes.no# = yes ) or ( #yes.no# = y ) then {
msg <you typed yes/y>
set numeric <answer; 1>
}
else {
if ( #yes.no# = no ) or ( #yes.no# = n ) then {
msg <you typed no/n>
set numeric <answer; 1>
}
else msg <You didn't type Yes/Y/No/N... Please re-enter your answer!>
}As you see, it'll go in one loop until you enter Y/Yes/N/No.
... I'd personally put it into a function, so you could pass it the conditionals/whatever and recieve an answer or not (1 or 0)...
You could then expand it from Yes/Y/No/N to:
N/North/E/East/W/West/S/South/U/Up/D/Down/C/Crack...
steve the gaming guy
11 Aug 2005, 20:56Great thanks! I'll try it out!