Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Meny on Sun 09/12/2007 00:51:41

Title: How to make a Text Box?
Post by: Meny on Sun 09/12/2007 00:51:41
Hi, I am kind of new at this, I am working with AGS for a year or less but I don't know everything.
Ok, the problem is that I can't make a text box. I had never done it before and when I had tried I had failed.
I tried to search for a solution in here but I failed again, I was never good in this. (:
So, in the game that I'm working on now, I want the player to use his laptop and search in the "web" for something (to "google"), and when I check the guide and copy the orders it tell me that they are old.
So what do you think should I do? If you can't bring me the directly the answer, maybe you can provide me a link to some place that answers it.

Sorry for my bad english.. :) this forum ROCKS!

Thank you very much!                 
Title: Re: How to make a Text Box?
Post by: Scorpiorus on Sun 09/12/2007 10:57:10
Hello and welcome to the forums! :)

As for your question, create a new GUI in the GUI Editor. Next click the "Add GUI Text Box" button and "draw" a textbox within the GUI area. Give this newly created textbox a script name. Double-click the textbox to add a function into the main global script to handle user input; add some code to test it in there:


function textbox-script-name-here_Activate(GUIControl *control) {

    // do the following when the player pressed the Enter key while
    // the textbox's GUI is being shown.

    Display( "You have just typed-in: %s", control.AsTextBox.Text );
}


See if it helps you to start getting it worked out.
Title: Re: How to make a Text Box?
Post by: Meny on Wed 12/12/2007 04:12:01
Thank You!  ;D
It work's, but I have still more problems. First of all what actually â€"
control.AsTextBox.Text mean?
Second thing, I want to make some few possibilities. Like, when the player put some specific text he will get one thing and when he will put something different he will get other thing.

One more question, I try to put not an English text and it can't show it, despite the font can support it. Why it happen? It just can't be?
   
Title: Re: How to make a Text Box?
Post by: Khris on Wed 12/12/2007 06:56:35
1. The function is called with the parameter "control", it's a pointer to the textbox itself.
You can use it e.g. to get the text that was typed in, as was shown by Scorpiorus.
However, the pointer is still formatted as GUIControl. To convert it to an actual textbox, you have to use the .AsTextBox method. Adding .Text will then return the text that was typed in by the player.

To react to the text, you can do this:

function textbox-script-name-here_Activate(GUIControl *control) {

  String s=control.AsTextBox.Text;

  if (s=="Hello") Display("Hello yourself!");
  if (s=="I want") player.AddInventory(inventory[1]);
}


About the font: try changing the textbox's font to the one you imported. In the GUI editor, select the textbox, then put the font's number into the Font field in the properties pane.
Title: Re: How to make a Text Box?
Post by: Meny on Wed 12/12/2007 23:54:02
Thank you!
Now I know how to work with the text box. At least the basics.  ;)