How do I make those teleport GUIs? (SOLVED)

Started by Edwin Xie, Sun 24/10/2004 05:38:44

Previous topic - Next topic

Edwin Xie

How do I? I want it to be like those original debug teleport GUIs only with another background color, but I can't seem to do this. If you aren't really familiar with these, there is a label at the top saying "Enter new room: (in room (the current room number the player is in))" and at the bottom, a textbox where you enter a room number to go there, and then at the right is an "OK" button which is like pressing the 'Enter' key on the keyboard when a textbox is around and then a cancel button at the bottom of the 'OK" button. Thanks for your help.

EDIT: Sorry for not making this shown as solved, but I will right now.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Goot

Go to the GUIs plane thingy on the side bar (read the part in the manual about making GUIs first) and make a new GUI. Make a label for the text, a text box for entering the number, and a button for 'ok.' Whenever interface click is run with either the text box (for pressing enter) or the button, use GetTextBoxText and StrToInt to find the room number. Then do NewRoom(); and MoveToWalkableArea(GetPlayerCharacter()); if you want the player to be automatically put on a walkable area.

Radiant

Also, it would be a good idea to check if the room number is within range, because NewRoom'ing to an invalid room will crash your game.

Edwin Xie

Sigh, I don't know if this information is specific enough for me.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Goot

Have you read the part of the help section called customizing the GUIs? If not, go read it. It'll tell you everything you need to know.
(To get to it, go into AGS, go help>help topics. Go to the search tab and type GUI. That should find it.

Edwin Xie

I have read that but it is very difficult to script it, there once was a problem though too.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Goot

Alright, here's the script. You've got to make a gui with a label that says "Enter room to teleport to," a text box, and a button that says "ok."

top of global script:

int buffer;
int roomnumber;

function interface_click(int interface,int button){ //this is in the
//global script

//there is a bunch of other stuff here, before interface click ends

if(Interface==NAME){//replace name with gui name or number of
//your gui

if((button==x)||(button==y)){//x and y are object numbers for
//button and text box (object num. explained below)

GetTextBoxText(NAME,x,buffer); //replace name with gui name,
//replace x with text box object number, which can be found by
//clicking on the button object and then looking for the object
//number in the little blue window.

roomnumber=StringToInt(buffer);
if(roomnumber<x){//replace x with max room number+1
NewRoom(roomnumber);

MoveToWalkableArea(GetPlayerCharacter());
}
else{
display ("That's not a valid room number.");
}
}
}

Phew!

Edwin Xie

#7
I'm afraid there is a big gap of rooms of nothing (no backgrounds no file, etc.) between room 2 and room 100. :P
EDIT: Plus, I want a label on the top to indicate which room it is in.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Hellomoto

Is this an interface for you to use whilst debugging, or for a player to use?

If it is for your own use, then, you could use the above function, however on the line:

Code: ags

if(roomnumber<x){

change it to the following code:
Code: ags

if((roomnumber<x) && (roomnumber < 2) && (roomnumber > 100))


that should work.


However, if the interface is for a player, you would be better giving each room a name (unless you have given a list of available rooms, in which case, you could still use the above code). Giving each room a name could be done in numerous ways. The simplest of which would be to add a textbox and then the following (or similar) code

Code: ags

string room;
GetTextBoxText(teleport GUI name or number, Text object number, room);

if((room == "Engine Room") || (room == "engine room")){ //or other possible variations which could be entered
NewRoom(room number);
}
else{
   if((room == "Brig") || ("brig"){
      NewRoom(room number);
   }
}


repeat the above if statement for other possible rooms, changing the possible entry's

Once you have entered all of the possible room names and room changes, add the following code

Code: ags

else{
   Display("The room name you entered does not seem to exist");
   SetTextBoxText(GUI number, text box number, "");
}


You could always set a default room to go to, if the entered room cannot be detected.

There are of course better methods of solving the same problem, however that seemed the simplest. I would reccomend using the AGS parser to check the entered string, otherwise your script could become very long and untidy.

However, the advantages can be great, you only need define the rooms which you want the player to be able to reach, which would stop them from accessing rooms like the closing sequence or other screens which you do not want to give access to. Also, you would gain the ability, to add new rooms to the list, when a condition becomes true.

Edwin Xie

Here is the script (a little modified to suit my needs), but I will have to update it everytime I make a new room.

string buffer;
  int roomnumber;
  if(interface==11){
    if((button==0)||(button==1)){
      GetTextBoxText(11,0,buffer);
      roomnumber=StringToInt(buffer);
      if((roomnumber<3)||(roomnumber==100)){
        NewRoom(roomnumber);
        MoveToWalkableArea(GetPlayerCharacter());
        GUIOff(11);
        }
    else {
      Display ("That's not a valid room number.");
      }
    }
    else if (button==2) GUIOff(11);
    }
  }

For the label (with a little help from strazer), I put in repeatedly_execute function:
CentreGUI(11);
  int curroomnumberint;
  curroomnumberint=character[GetPlayerCharacter()].room;
  string curroomnumberstr;
  StrFormat(curroomnumberstr, "Enter new room: (in room %d)", curroomnumberint);
  SetLabelText(11, 3, buffer);
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

SMF spam blocked by CleanTalk