Getting a Textbox to work - I need to know all the steps involved please

Started by Igthorn, Mon 21/04/2014 17:04:00

Previous topic - Next topic

Igthorn

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

Slasher

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

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....


Igthorn

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.


Slasher

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.



Igthorn


SMF spam blocked by CleanTalk