Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Em on Sun 22/02/2009 09:56:44

Title: my GUI text box won't give the player a chance
Post by: Em on Sun 22/02/2009 09:56:44
Hello,
I'm trying to make a the player enter a password into a text box when they try to use a door to be able to progress in the game.
I've made a GUI with a text box as described in the PDF guide and in an earlier forum post back in January. This duly appears when the player interacts with the door, but doesn't give the player time to enter anything before the next thing happens - it goes straight to the "wrong password" type response.
I have tried setting my GUI properties to both "pause game when shown" and "normal, initially off", but this makes no difference. Do I need to block something somewhere?

Here is what I've done, forgive me if it doesn't look too nice, I'm new to this.

function hBathdoor_Interact()
{
cDoorvoice.Say("What's the password?");
gPassword.Visible=true;
if (TextBox1.Text=="cheese"){
cDoorvoice.Say("Come on in.");}
else {cDoorvoice.Say("Nope.");
}
TextBox1.Text="";
}

What haven't I done? Thanks a lot for your help.
Em
Title: Re: my GUI text box won't give the player a chance
Post by: Akatosh on Sun 22/02/2009 10:38:45
What your code does is show the player a text box, then immediatly check its contents before the player has any chance to enter something. I recommend using the Game.InputBox command, but if you absolutely have to use your custom password GUI, you should add a "Submit" button to your GUI (if you haven't already) and put this part of the code


if (TextBox1.Text=="cheese"){
cDoorvoice.Say("Come on in.");}
else {cDoorvoice.Say("Nope.");
}
TextBox1.Text="";


in its interaction section. I hope I'm making sense, I'm not exactly awake yet...  ;)
Title: Re: my GUI text box won't give the player a chance
Post by: Em on Sun 22/02/2009 11:44:01
Hurrah, I've added a button, it seems to be working now.
Sorry to be asking questions so early on a sunday morning...
Thanks for your help!
Title: Re: my GUI text box won't give the player a chance
Post by: AdamM on Sun 22/02/2009 16:19:24
Remember that if you don't want to use a button, you can also use the player pressing Return as a trigger. The function that is called when this happens is OnActivate, and you'll find it in the Events List for your Text Box.
Title: Re: my GUI text box won't give the player a chance
Post by: Em on Sun 22/02/2009 17:02:17
thanks a lot, I thought I'd read that somewhere!
There's so much to take in though when you're new to AGS...
Title: Re: my GUI text box won't give the player a chance
Post by: Trent R on Sun 22/02/2009 18:03:23
Or, you do both. Just call the button's event from the textbox, or vica versa.

~Trent
Title: Re: my GUI text box won't give the player a chance
Post by: Khris on Sun 22/02/2009 19:14:57
Or enter the function's name in both fields.
Title: Re: my GUI text box won't give the player a chance
Post by: Em on Sun 22/02/2009 20:11:45
wow, so many possibilities! I'll try them out.
thanks a lot for all your answers.
Em