Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: red runner on Sun 13/01/2008 03:04:32

Title: Putting GUIs in a room
Post by: red runner on Sun 13/01/2008 03:04:32
I know what your thinking, so before we start, I would just like the say that I've searched the manual and the forums, and I have not found the answer to my question.

I would like to put a text parser into one of my rooms. I've created a GUI with a text box in it, but how do I put it in the game?

I'm trying to create a computer terminal like in 7 Days a Skeptic, so if you could tell me how to do it, that would be most helpful. ???
Title: Re: Putting GUIs in a room
Post by: Khris on Sun 13/01/2008 07:09:44
GUIs are room-independent, so you just need to turn them visible to display them.
In the room, put something like "gInput.Visible = true;" into the appropriate function, e.g. the interact script function of the power button's hotspot.

Textbox GUI controls come with a "name_Activate" function that's called if the player hits the enter key.
To react to the entered text, put something like this inside the function:
function CommandTextBox_Activate(GUIControl g) {
  if (g.Text.LowerCase() == "hello") CallRoomScript(1);
  else if (g.Text.LowerCase() == "mail") CallRoomScript(2);
  ...
  else CallRoomscript(0);
  g.Text == "";
}

Then code the reactions in the room script:
function on_call(int p) {
  if (p==0) Display("Unable to comply.");
  if (p==1) Display("Hello yourself!");
  if (p==2) {
    Display("There are two mails in the inbox:");
    ...
  }


("gInput" and "CommandTextBox" are just examples; you'll have to use your own script names for the code to work.
I chose to react in the room script to allow room-dependent code to be executed after certain commands. It's not necessary to use CallRoomScript/on_call to react to the typed command.)
Title: Re: Putting GUIs in a room
Post by: red runner on Sun 13/01/2008 19:07:52
I'm still a little confused. What scripts should I use where? I tried it out, but it keeps erring.