Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Igthorn on Mon 21/04/2014 17:04:00

Title: Getting a Textbox to work - I need to know all the steps involved please
Post by: Igthorn on Mon 21/04/2014 17:04:00
Hi All
I am obviously not understanding something about the use of textboxes and was hoping that a guru could walk me through it please.

I create a gui
I add a label and textbox on the gui.

When my PC talks to a hotspot (called hEgg), I want the gui to pop up and ask for the player to enter an answer.
I want to compare that answer to a number of possible answers and in some cases I want the gui to request a second answer (like a part two)

I understand (or think I do) that I need the text property of the textbox - but I dont understand how to force the player to enter something before I make the program check the string values.
I initially used
answer = tinputscroll.text

but realised that this just takes the value - it doesnt seem to wait for the user to type something.     

I have trawled the forum for hours but I am getting more confused rather than less so. Please can I have step by step instructions (and cheekily, explanations if possible) to resolve this.

Thanks
Title: Re: Getting a Textbox to work - I need to know all the steps involved please
Post by: Slasher on Mon 21/04/2014 17:55:18
Well the basic way to start is this :

Example

Make a GUI name it gPasswordGUI

Add a label: Text: Please enter Password

Add a TextBox: Name: tbInput

Add Button: Name it: btnEnter Text: OK (This will check the sting input)

On Button click (properties pane of button btnEnter) add:

Code (ags) Select

function btnEnter_OnClick(GUIControl *control, MouseButton button)
{
 
 
    if (tbInput.Text == "PASSWORD") // the word you want as your password
    {
      // If answer is correct put code here, like opening new Password gui
         
     }
  else
{
   // Code here if password is wrong
   
   }
}



You can add more than one answer by also using else if...

You can take it from here....

Title: Re: Getting a Textbox to work - I need to know all the steps involved please
Post by: Igthorn on Mon 21/04/2014 19:30:49
Hi

That makes sense but I am not sure how to activate it from the "talk to hotspot" event?

Thanks so much for your advice.

Title: Re: Getting a Textbox to work - I need to know all the steps involved please
Post by: Slasher on Mon 21/04/2014 19:40:12
Quick answer

Set the password gui 'initially off' in its events pane.

Then click the hotspot events pane (the hotspot that opens the password gui) and click talk to hotspot:

The talk to hotspot function will automatically appear in the room script.

Simply add gPassword.Visible=true;

The Password gui will appear (become visible).

To close the Password gui simply add gPassword.Visible=false;

Hope this helps.


Title: Re: Getting a Textbox to work - I need to know all the steps involved please
Post by: Igthorn on Mon 21/04/2014 19:59:37
It does work!!!

Thanks so much for your quick response.