Unlocking a door through text input

Started by , Sat 17/03/2007 17:50:29

Previous topic - Next topic

bowtolaura

Hello everyone,

   Here I am again! It took me only one day to run into another problem! I'll tell you know, you'll be seeing a lot of me around here in the next few days.   ;)
   In my game there is a locked door that can only be opened by answering five questions correctly. I have it so the player answers the questions by typing in a response in a GUI text box. Here is where I run into my problem. How can I tell the computer that the player's response is wrong or right? And how can have the door unlocked once the player answers all five questions correctly? Should I use a GUI text box in the first place?
   Just in case I am not clear enough, I'll give you an example of how I want this to work:

There is a computer built into a locked door. The only way to unlock the door is to type in five correct answers to five questions that are included in the computer. Let's say the first question is: "What is 2 + 2?" The player makes a mistake and types in "3". The computer tells him that is "incorrect input." The player tries again and types in "4". Bingo! The door is unlocked and the player opens the door.

   How should I go about doing this?

   I hope I am not creating spam with all my basic questions. Since my game is a birthday gift (and the birthday is coming up soon) I don't have a lot of time to really search in the AGS Help File or the Knowledge Base. Do let me know if my posts fall into spam criteria!

Sincerely,
Bowtolaura




   

Akatosh

Well, the most basic method would be:

Code: ags

String iput=Game.InputBox("What is 2+2?");
if (iput=="4") //your code here
else Display("Wrong code!");

bowtolaura

Akatosh,

   Where would I place this code?

Bowtolaura

Ashen

#3
Where/when do you want to ask the question? If it's when the player interacts with a Hotspot, it goes in the Hotspot interaction. If it's when they talk to another character, it goes in the 'Talk to Character' interaction... It's up to you. (Handy BFAQ article.)

Your questions aren't spam exactly (they're not trying to sell us anything, for starters), but they have mostly been ones that could've been answered by searching the forums, the BFAQ or the manual. I appreciate that you're on a deadline, but a couple of minutes searching shouldn't put you too far behind.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk