Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: viktor on Sun 04/07/2004 21:00:31

Title: two gui questions (solved)
Post by: viktor on Sun 04/07/2004 21:00:31
I have to a bit stoopid questions. I used the AGS tutorial to make my own quit GUI.
But when I use that quit gui it will only apear when I pres on the quit button. I wan't it to apear when for instance Esc or Ctrl+Q is pressed. How can I do that?

And is there any way to simply change the look of the defoult save load and quit GUIs?
Title: Re: two gui questions
Post by: Mr Jake on Sun 04/07/2004 21:06:41
look in the manual of details of 'on_key_press' and for the ACSII code table.
Title: Re: two gui questions
Post by: Hollister Man on Sun 04/07/2004 22:16:15
All you can 'quickly and easily' change about it is the message displayed.  It is stored in one of the global messages and can be changed in the editor.

Any other way you have to make your own GUI for it.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 06:40:17
crap. Maybee that could be in  the naxt version of AGS. The posibility to change these guis I mean.
Title: Re: two gui questions
Post by: Goot on Mon 05/07/2004 06:50:34
It's not too hard to change. Go into the global script into on_key_press. Wherever it says: QuitGame(1); replace it with InterfaceOn(int GUI); int GUI=the number GUI that the quit thing is.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 07:31:26
is there any tutorial on how to make a custom save and load gui. Becouse I think that would be a bit more complicated than the quit gui. 

EDIT: Oh. Thanks BTW. I fixed the gui and it works perfectly now.

EDIT: I found a tutorial. But this mesage keeps poping up:
(http://www.2dadventure.com/ags/untitled3.png)

and this is the script I used:

string text;

int index;



function on_key_press(int keycode) {



if (keycode==363) {
   

// Press F5

SetTextBoxText(1,0,"");
   

// Clear Text box

ListBoxSaveGameList(1,3);
   

// Fill List Box with saved games

index=ListBoxGetNumItems(1,3);
   

// Count how many saved games there are         

if (index>19){
   

// If saved games 20 (maximum)

Display("You must overwrite a previous saved game");
   

// Display warning

}

InterfaceOn(1);
   

// Bring Save interface on             

}



if (keycode==365) {
   

// Press F7

ListBoxSaveGameList(0,0);
   

// Fill List box with saved games

InterfaceOn(0);
   

// Bring restore Interface on

}





function interface_click(int interface, int button) {

if (interface==0) {
   

// if Restore interface

if (button==1) {
   

// if cancel is pressed

InterfaceOff(0);
   

// Close interface

else { index=ListBoxGetSelected(0,0);
   

// else get the selected game

RestoreGameSlot(savegameindex[index]);}
   

// restore the game

}
}



if (interface==1) {
   

// if save interface

if (button==0) {
   

// if enter is pressed

index=ListBoxGetNumItems(1,3);
   

// Count saved games

if (index<20) {
   

// if less than 20

GetTextBoxText(1,0,text);
   

// Get the typed text

InterfaceOff(1);
   

// Close interface

SaveGameSlot(index+1,text); }
   

// Save game (text as description)

else {
   

// if saved games are 20

index=ListBoxGetSelected(1,3);
   

// Get the selected save game

GetTextBoxText(1,0,text);
   

// Get the typed text

InterfaceOff(1);
   

// Close the interface

SaveGameSlot(savegameindex[index],text); }
   

// Overwrite the selected game



}

if (button==2) InterfaceOff(1);
   

// if cancel is pressed close interface
Title: Re: two gui questions
Post by: Gilbert on Mon 05/07/2004 09:51:09
That means, you're not adding the content to be added to on_key_press() in the on_key_press() function already defined, but started making a new one.

Just move the content to be added to that function into the ORIGINAL function and delete your new definition of it.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 10:16:51
Quote from: Gilbot V7000a on Mon 05/07/2004 09:51:09
That means, you're not adding the content to be added to on_key_press() in the on_key_press() function already defined, but started making a new one.

Just move the content to be added to that function into the ORIGINAL function and delete your new definition of it.

I'm going to pretend I understood that and ask you politely to eksplain it to me again 
slowly. (http://forum.irts.si/images/smiles/icon_redface.gif)
Title: Re: two gui questions
Post by: Alynn on Mon 05/07/2004 10:47:51
on_key_press already exists in the global script... you need to place your code in that function... not create a new function called on_key_press
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 10:58:34
what about that string text and index? Where do I put that in?
Title: Re: two gui questions
Post by: Sam. on Mon 05/07/2004 12:28:39
Go onto the script menu and then click on_key_press

then change this line: 
if (keycode==17)  QuitGame(1);   // Ctrl-Q
to:  if (keycode==17)  GUIon(intGUInumber);   // Ctrl-Q

then at the bottom of the list add this line:
if (keycode==27)  GUIon(intGuinumber);   // Escape

Then your gui will open when ctrl-Q is pressed and escape. (change intGUINUmber to the number of your gui)
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 13:10:18
if (interface==0) {// if Restore interface
  string text;
  int index;
  if (button==1)

and:

if (interface==1) { // if save interface
  string text;
  int index;
  if (button==0)

Also, you might want to call the GUIs by name instead of number, e.g. LOADGUI and SAVEGUI, as it's easier to tell which bit of the script refers to which GUI then.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 13:22:57
Ok now I don't know anithing. What's with all theese scripts.

Zootfruit: Thanks for your efort, but I fixd that problem. Now I need help with the LOAD and QUIT GUI.

ASHEN: What will that script do. I already have a script. I got all confused now. I took a good look at your script but I here is a little problem with it. I'm missing the button functions. The buttons in the GUI have no function. Do you understand what I mean?
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 13:38:41
Sorry, Viktor, should've been clearer. The 'string text;' and 'int index;' line go at the beginning of the script you've alread got. In full (but cleaned up a little):

function interface_click(int interface, int button) {

if (interface==0) { // if Restore interface
Ã,  string text;
Ã,  int index;
Ã,  if (button==1) {// if cancel is pressed
Ã,  Ã,  InterfaceOff(0); // Close interface
Ã,  }

Ã,  else {
Ã,  Ã,  Ã, index=ListBoxGetSelected(0,0); // else get the selected game
Ã,  Ã,  Ã, RestoreGameSlot(savegameindex[index]);
Ã,  } // restore the game
}

if (interface==1) { // if save interface
Ã,  string text;
Ã,  int index;
Ã,  if (button==0) { // if enter is pressed
Ã,  Ã,  index=ListBoxGetNumItems(1,3);Ã,  // Count saved games
Ã,  Ã,  if (index<20) { // if less than 20
Ã,  Ã,  Ã,  GetTextBoxText(1,0,text); // Get the typed text
Ã,  Ã,  Ã,  InterfaceOff(1); // Close interface
Ã,  Ã,  Ã,  SaveGameSlot(index+1,text);
Ã,  Ã,  } // Save game (text as description)

Ã,  Ã,  else { // if saved games are 20
Ã,  Ã,  Ã,  index=ListBoxGetSelected(1,3); // Get the selected save game
Ã,  Ã,  Ã,  GetTextBoxText(1,0,text); // Get the typed text
Ã,  Ã,  Ã,  InterfaceOff(1); // Close the interface
Ã,  Ã,  Ã,  SaveGameSlot(savegameindex[index],text);
Ã,  Ã,  } // Overwrite the selected game
Ã,  }

  if (button==2) InterfaceOff(1); // if cancel is pressed close interface
}

Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 13:46:40
so I just copy this in to the global scriot?
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 13:52:21
Yes, replacing any

if (interface == 0) {
  //whatever
}

if (interface == 1) {
  //whatever
}

that might already be there. Another point: make sure they refer to the right GUIs, by default 0 and 1 are the STATUSLINE and ICONBAR GUIs.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 19:32:57
well this is what I+ve got in now. (I hawen't added a the lines you gave me)

function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  InterfaceOn(3);    // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room


Do I have to delete anithing of this?
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 19:47:14
Looks fine, except you'll want to change:

  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7

to

  if (keycode==363) GUIOn(1);   // F5 Save GUI
  if (keycode==365) GUIOn(0);  // F7 Load GUI

Or what ever numbers the save and load GUIs are. The rest of it goes under:

function interface_click(int interface, int button) {
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 19:59:51
I think I'm never gona get this right.

This mesage pops up

(http://www.2dadventure.com/ags/untitled4.png)
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 20:01:37
Can you post the lines around line 89? It looks like you've missed a } somewhere.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 20:13:36
well. I posted the part that you gave me. I would shure apritiante it if you would check it. The save gui number is 5 and the load is 4.
http://www.2dadventure.com/ags/untitled5.png

and this is the part around line 89. But thats a on mouse press comand.
http://www.2dadventure.com/ags/untitled6.png
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 20:29:54
OK, I see the problem. You need to take everything afterÃ,  function interface_click(int interface, int button) { out ofÃ,  function on_key_press(int keycode) { and put it in toÃ,  function interface_click(int interface, int button) { (which you can see at the bottom of the second picture you posted.)

So, you should have:
function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==17)Ã,  InterfaceOn(3);Ã,  Ã,  // Ctrl-Q
Ã,  if (keycode==363) GUIOn(5);Ã,  Ã, // F5 Save GUI
Ã,  if (keycode==365) GUIOn(4);Ã,  // F7 Load GUI
Ã,  if (keycode==367) RestartGame();Ã,  // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==9)Ã,  Ã, show_inventory_window();Ã,  // Tab, show inventory
Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
}

Then, further down the script (line 105 in the second screenshot):
function interface_click(int interface, int button) {

Ã,  if (interface == ICONBAR) {
Ã,  // whatever is already here
Ã,  }Ã,  // end ICONBAR

Ã,  if (interface == INVENTORY) {
Ã,  Ã,  // whateverÃ,  is already here
Ã,  } // end INVENTORY

Ã,  if (interface == 3) {
Ã,  // Quit Gui interactions
Ã,  } // end Quit GUI

if (interface==4) { // if Restore interface
Ã,  string text;
Ã,  int index;
Ã,  if (button==1) {// if cancel is pressed
Ã,  Ã,  InterfaceOff(4); // Close interface
Ã,  }

Ã,  else {
Ã,  Ã,  Ã, index=ListBoxGetSelected(4,0); // else get the selected game
Ã,  Ã,  Ã, RestoreGameSlot(savegameindex[index]);
Ã,  } // restore the game
} // end Load GUI

if (interface==5) { // if save interface
Ã,  string text;
Ã,  int index;
Ã,  if (button==0) { // if enter is pressed
Ã,  Ã,  index=ListBoxGetNumItems(5,3);Ã,  // Count saved games
Ã,  Ã,  if (index<20) { // if less than 20
Ã,  Ã,  Ã,  GetTextBoxText(5,0,text); // Get the typed text
Ã,  Ã,  Ã,  InterfaceOff(5); // Close interface
Ã,  Ã,  Ã,  SaveGameSlot(index+1,text);
Ã,  Ã,  } // Save game (text as description)

Ã,  Ã,  else { // if saved games are 20
Ã,  Ã,  Ã,  index=ListBoxGetSelected(5,3); // Get the selected save game
Ã,  Ã,  Ã,  GetTextBoxText(5,0,text); // Get the typed text
Ã,  Ã,  Ã,  InterfaceOff(5); // Close the interface
Ã,  Ã,  Ã,  SaveGameSlot(savegameindex[index],text);
Ã,  Ã,  } // Overwrite the selected game
Ã,  }

Ã,  if (button==2) InterfaceOff(5); // if cancel is pressed close interface
} // end Save GUI
} // end function interface_click.

Edited, as I realised I hadn't changed the InterfaceOff()'s and GetTextBoxText()'s and that.
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 20:54:27
DAMN IT NOW I'M PISSED!!! >:(
NOW THE FUCKING CUSTOM QUIT GUI WON'T WORK!
What's wrong? And also when I save the game and want to load it no saved game is displayed in the load screen? WHY!?

P.S.
Sorry for my behawior in the first two lines but now I've been trying all day to get this thing working and whn I finaly find a solution something els goes wrong.
Title: Re: two gui questions
Post by: Ashen on Mon 05/07/2004 21:27:10
Make sure all the
GetTextBoxText();
ListBoxGetSelected();
ListBoxGetNumItems();

refer to the right things. Currently it assumes
Load GUI Object 0 is a List Box
Save GUI Object 0 is a Text Box
Save GUI Object 3 is a List Box

Also, you need to replace the lines:
Ã,  if (keycode==363) GUIOn(5);Ã,  Ã, // F5 Save GUI
Ã,  if (keycode==365) GUIOn(4);Ã,  // F7 Load GUI

with:
Ã,  if (keycode==363) {
Ã,  Ã,  Ã,  ListBoxSaveGameList(5,1);
Ã,  Ã,  Ã,  GUIOn (5);Ã, 
Ã,  Ã,  }  // F5 Save GUI
Ã,  if (keycode==365) {
Ã,  Ã,  Ã,  ListBoxSaveGameList(4,0);
Ã,  Ã,  Ã,  GUIOn (4);Ã, 
Ã,  Ã,  }Ã,  // F7 Load GUI

Sorry, should've noticed that earlier. This is how the Load GUI knows what save games there are.

About the Quit GUI, you didn't change the code when you put this new stuff in, did you? What number was the Quit GUI - I guessed 3 but could've been wrong. What does the Quit GUI code say?
Title: Re: two gui questions
Post by: viktor on Mon 05/07/2004 22:02:09
I don't know what the quit gui says and I'm not going to check either. I'm to tired ::). You' ve been a big help. The load and save guis look and work good. I'm going to check the quit gui tomorow if you don't mind...
Title: Re: two gui questions
Post by: viktor on Tue 06/07/2004 10:08:18
Ok now I'm rested and ready to reply. That should have worked since the quit gui is in fact number 3.  I used the tutorial on the oficial AGS site if that would be of any help.
Title: Re: two gui questions
Post by: viktor on Wed 07/07/2004 20:14:28
c,mon people help me here!
Title: Re: two gui questions
Post by: Ashen on Wed 07/07/2004 20:20:03
What's the problem? Is the GUI not showing up at all, or is it just that the buttons aren't working? Either way, post the code.
Title: Re: two gui questions
Post by: viktor on Wed 07/07/2004 20:36:11
the code is already posted. I enterd what you geve me. The gui does show up but the butons don't work. the code that I used before you gave me yours is

if (interface == QUITGUI) {   
    if (button == 0) {
      QuitGame(0);
    }
    if (button == 1) {
      GUIOff(QUITGUI);
    }
  }   
Title: Re: two gui questions
Post by: Ashen on Wed 07/07/2004 20:51:24
Can't see anything wrong with that, apart from checking the obvious stuff:

1. Since you were tired, you didn't acccidentally put this bit in, did you?
  if (interface == 3) {
  // Quit Gui interactions
  } // end Quit GUI

That was just to show where the Quit GUI code goes.

2. Is the GUI called QUITGUI?

3. Are the buttons set to 'Run Script'?

4. Check the QUITGUI script isn't nestled in another GUIs script.

Probably nothing you haven't already checked, unfortunately.
Title: Re: two gui questions
Post by: viktor on Wed 07/07/2004 21:36:05
Yes I did put that part in. The quit gui worked befor I put that part in. Alkl the butons are set up corectly and the guis name is QUITGUI. 

I'll try to find that part delete it and replace it with the script I used before.
Title: Re: two gui questions
Post by: viktor on Wed 07/07/2004 21:43:47
everithing looks and works great now. Thanks a bunch. I'll be shure to mention you in the game.
Title: Re: two gui questions
Post by: viktor on Wed 07/07/2004 22:03:53
ok everithing is not OK. I was making the GUI in a test game and as it turned out I can't use those scripts in the game I am actualy making :'( :'((damn it why didn't I think of that before. I totaly forgot.)  The number of the quit gui is 7, load is 8 and save is 9. Averithing else is the same. What do I have to insert in to this script? I know that I'm a big bother when it comes to scripting so please be patient with me.

This is the script i hawe in the game

// main global script file

function DisplayText(int message_number, int x, int y) {

   int gui = TEXTGUI;
   SetGUIZOrder(gui, 1000);
   string text;
   GetMessageText(message_number, text);
   SetLabelText(gui, 0, text);
   SetGUIPosition(gui, x ,y);
   GUIOn(gui);
   while (WaitMouseKey(100)==0) { }
   GUIOff(gui);
   Wait(1);
}


int clicked; //if you've processed the click
int timer; //keeps the track of how long you press the button

int mousex; //these are used to store the coordinates of where you right-
int mousey; //clicked, since the mouse coord. change while you select
            //mode on the verb coin...

int guix; //these on the other hand is used to figure out where you should
int guiy; //put the GUI. If we'd follow the mouse coord., it may appear to
          //high/low etc... more on that below.
         


#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
SetInvDimensions(45,50);
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {

if (IsGUIOn(2) == 0) { //is the GUI up?
if (clicked == 1) { //we check if someone clicked..
  if (IsButtonDown(LEFT) == 0) { //this executes if the button is released
    if (timer < 20) {
      ProcessClick(mousex,mousey,0);
      clicked=0; //stop that checking
      timer=0; //reset the timer
      //if the button isn't held more than 20 (about half a sec.), you'll
      //walk to the destination mousex,mousey...
      }
    }
  if (IsButtonDown(LEFT) == 1) timer++; //While it's held, timer is increasing
  if (timer >= 20) { //when you've held it for 20 (half a sec.), the GUI pops
    SetGUIPosition(2,guix,guiy);  //selfexplanatory? Oh, our GUI is numero 2.
    InterfaceOn(2); //turn the GUI on
    clicked=0; //guess what..
    timer=0; //and this?
    }
  }
}
else { //what will be checked when the GUI is infact on
  if (IsButtonDown(LEFT) == 0) { //what will happen if you release da button?
    if (GetGUIAt(mouse.x,mouse.y) == 2) {
      //this function checks if the cursor
      //is over an GUI
        int whatbutton;
        whatbutton = GetGUIObjectAt(mouse.x,mouse.y);
        InterfaceOff(2); //we'll turn the interface off
        Wait(1); //To make sure that the GUI is gone
        if (whatbutton > -1) ProcessClick(mousex,mousey,whatbutton+1);
          //This is the great part. First we check which button. Then, since
          //the buttons is set in the default cursor modes values subracted
          //by 1, we'll add one and we'll get the appropriate cursor mode.
          //Since GetGUIObjectAt() returns -1 if it's not over an button, it
          //would execute in walkmode if you're still inside the GUI-area when
          //releasing it. So first we make sure that you released on
          //a button, ie. that the int whatbutton is bigger than -1
        }
     else InterfaceOff(2); //otherwise, we'll simply turn it off, without s.t. else
     }
  }
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   InventoryScreen();  // Tab, show inventory
  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
    }
  else if (button==RIGHT) {
    if (GetCursorMode() == 4) SetCursorMode(0); //checks wether you use an inv.
else { InterfaceOn(3); SetCursorMode(2); SetMouseCursor(6); }   
// else InventoryScreen();
                       //brings up the usual Sierra inventory..
                       //In the next versions, it'll simulate a CMI-like
                       //inventory...
    }
  else if (button==LEFT) {  // left-clicking code
    if (GetCursorMode() == 4) ProcessClick(mouse.x,mouse.y,4);
    else { //these codes check wether you use an inventory or not..

    clicked = 1; //we trigger the calculating

    mousex = mouse.x; //we set these params to store the exact location of
    mousey = mouse.y; //where you clicked...

    guix = mousex - 25; //and we set the whereabout's for the GUI... and to
    guiy = mousey - 25; //center the GUI, we'll remove 25 (see below)...

    if (guix < 0) guix = 0; if (guix > 269) guix = 269;
    if (guiy < 0) guiy = 0; if (guiy > 149) guiy = 149;
      //Now we'll check these so the verbcoin won't appear to close to
      //the edges. If not altered, it may be impossible to select certain
      //commands! Why these numbers? Well, the GUI is exactly 50x50, which...

      //(NOTATE: the GUI is 50x50, not the graphic. That's why the GUI never will be
      //displayed without some space to the screen edge!!!)

      //...means that to center it by our clicks, it must be set to the mouse
      //coordinates - 25... AND, since AGS first coord. is (0,0), you
      //subtract 1 from the values. Also, as all other things, it spawns from
      //the top-right corner, so in the top and left side, well simply put it
      //close as possible ie. 0. On the other side, well take the largest value
      //(which is 319) and subtract 50 (the size of the GUI) and the equalent
      //from the bottom (199-50)
      }
    }
  }
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
////////////////////////////////////////////////
// Inventory-GUI                              //
////////////////////////////////////////////////

if (interface == 3) {

      if (button == 0) {     
         InterfaceOff(3);
         SetDefaultCursor();

      }
      if (button == 1) {     
         InterfaceOff(3);
         SetDefaultCursor();

      }
      if (button == 2) {     
         InterfaceOff(3);
         SetDefaultCursor();

      }   
   }

}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart inventory1_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory1_a() {
  // script for inventory1: Use inventory on this item
SetCursorMode(MODE_USE);
 
}
#sectionend inventory1_a  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart inventory1_b  // DO NOT EDIT OR REMOVE THIS LINE
function inventory1_b() {
  // script for inventory1: Use inventory on this item
 
DisplayText(502, 100, 100);
 
}
#sectionend inventory1_b  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory4_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory4_a() {
  // script for inventory4: Use inventory on this item
DisplayText(503, 100, 100);
   
}
#sectionend inventory4_a  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart character7_a  // DO NOT EDIT OR REMOVE THIS LINE
function character7_a() {
  // script for character7: Talk to character
StopMoving(GAY); // you have to stop characters before manipulating x and y coordinates
character[GAY].room = -1; // number of room you want to put him in
character[GAY].x = 75; // x-coordinate of character in new room
character[GAY].y = 136; // y-coordinate of character in new room
 
}
#sectionend character7_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory7_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_a() {
  // script for inventory7: Use inventory on this item
DisplayText(504, 100, 100);
 
 
}
#sectionend inventory7_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory7_b  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_b() {
  // script for inventory7: Use inventory on this item
DisplayText(504, 100, 100); 
}
#sectionend inventory7_b  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory7_c  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_c() {
  // script for inventory7: Use inventory on this item
DisplayText(504, 100, 100); 
}
#sectionend inventory7_c  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory5_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory5_a() {
  // script for inventory5: Look at inventory item
DisplayText(505, 100, 100); 
}
#sectionend inventory5_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory6_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory6_a() {
  // script for inventory6: Look at inventory item
 
DisplayText(506, 100, 100);
}
#sectionend inventory6_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory7_d  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_d() {
  // script for inventory7: Look at inventory item
DisplayText(507, 100, 100); 
}
#sectionend inventory7_d  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory8_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory8_a() {
  // script for inventory8: Look at inventory item
DisplayText(508, 100, 100); 
}
#sectionend inventory8_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory7_e  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_e() {
  // script for inventory7: Use inventory on this item
DisplayText(504, 100, 100); 
}
#sectionend inventory7_e  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart character4_a  // DO NOT EDIT OR REMOVE THIS LINE
function character4_a() {
  // script for character4: Talk to character
StopMoving(JOE); // you have to stop characters before manipulating x and y coordinates
character[JOE].room = -1; // number of room you want to put him in
character[JOE].x = 75; // x-coordinate of character in new room
character[JOE].y = 136; // y-coordinate of character in new room
 
 
}
#sectionend character4_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character4_b  // DO NOT EDIT OR REMOVE THIS LINE
function character4_b() {
  // script for character4: Talk to character
RunDialog  (72);
}
#sectionend character4_b  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character4_c  // DO NOT EDIT OR REMOVE THIS LINE
function character4_c() {
  // script for character4: Talk to character
RunDialog  (72); 
}
#sectionend character4_c  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character4_d  // DO NOT EDIT OR REMOVE THIS LINE
function character4_d() {
  // script for character4: Talk to character
RunDialog  (72); 
}
#sectionend character4_d  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character4_e  // DO NOT EDIT OR REMOVE THIS LINE
function character4_e() {
  // script for character4: Talk to character
RunDialog  (72); 
}
#sectionend character4_e  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart inventory4_b  // DO NOT EDIT OR REMOVE THIS LINE
function inventory4_b() {
  // script for inventory4: Use inventory on this item
DisplayText(509, 100, 100);
     
}
#sectionend inventory4_b  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart character8_c  // DO NOT EDIT OR REMOVE THIS LINE
function character8_c() {
  // script for character8: Use inventory on character
StopMoving(MAN); // you have to stop characters before manipulating x and y coordinates
character[MAN].room = -1; // number of room you want to put him in
character[MAN].x = 75; // x-coordinate of character in new room
character[MAN].y = 136; // y-coordinate of character in new room
   
 
}
#sectionend character8_c  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character8_d  // DO NOT EDIT OR REMOVE THIS LINE
function character8_d() {
  // script for character8: Use inventory on character
DisplaySpeech(GetPlayerCharacter(), "Hm. He forgot his tool box. HEHEHE!"); 
}
#sectionend character8_d  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character8_a  // DO NOT EDIT OR REMOVE THIS LINE
function character8_a() {
  // script for character8: Talk to character
 
DisplaySpeech(GetPlayerCharacter(), "I have to get him to stop working somehow.");
}
#sectionend character8_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character6_a  // DO NOT EDIT OR REMOVE THIS LINE
function character6_a() {
  // script for character6: Talk to character
StopMoving(STE); // you have to stop characters before manipulating x and y coordinates
character[STE].room = -1; // number of room you want to put him in
character[STE].x = 75; // x-coordinate of character in new room
character[STE].y = 136; // y-coordinate of character in new room
   
}
#sectionend character6_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory10_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory10_a() {
  // script for inventory10: Look at inventory item
DisplayText(508, 100, 100); 
 
}
#sectionend inventory10_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character7_b  // DO NOT EDIT OR REMOVE THIS LINE
function character7_b() {
  // script for character7: Talk to character
DisplaySpeech(GetPlayerCharacter(), "No. I hawen't sorted things out with the Battle Of The Bands Asisiaton yet."); 
}
#sectionend character7_b  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character7_c  // DO NOT EDIT OR REMOVE THIS LINE
function character7_c() {
  // script for character7: Talk to character
DisplaySpeech(GetPlayerCharacter(), "No. I hawe to call the Battle Of The Bands asosiation first."); 
}
#sectionend character7_c  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character4_f  // DO NOT EDIT OR REMOVE THIS LINE
function character4_f() {
  // script for character4: Talk to character
DisplaySpeech(GetPlayerCharacter(), "I'd  better fix the tire before I tell him to go to the wan."); 
}
#sectionend character4_f  // DO NOT EDIT OR REMOVE THIS LINE



Title: Re: two gui questions
Post by: Ashen on Wed 07/07/2004 22:39:46
It's OK, the hard bit's behind you now. ;) You just need to

Change the on_key_press section to this:

function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  GUIOn(7);   // Ctrl-Q
  if (keycode==363) {
      ListBoxSaveGameList(9,1);
      GUIOn (9); 
    }  // F5 Save GUI
  if (keycode==365) {
      ListBoxSaveGameList(8,0);
      GUIOn (8);
    }  // F7 Load GUI
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   InventoryScreen();  // Tab, show inventory
  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}


And change the interface_click section to this:

function interface_click(int interface, int button) {
////////////////////////////////////////////////
// Inventory-GUI                              //
////////////////////////////////////////////////

  if (interface == 3) {
    if (button == 0) {     
      InterfaceOff(3);
      SetDefaultCursor();
    }
    if (button == 1) {     
      InterfaceOff(3);
      SetDefaultCursor();
    }
    if (button == 2) {     
      InterfaceOff(3);
      SetDefaultCursor();
    }   
  }

  if (interface == 7) { // if Quit interface
    if (button == 0) { // if Quit button
      QuitGame(0);
    }
    if (button == 1) { // if Play button
      GUIOff(7);
    }
  } // end Quit GUI

  if (interface==8) { // if Restore interface
    string text;
    int index;
    if (button==1) {// if cancel is pressed
      GUIOff(8); // Close interface
    }

    else {
     index=ListBoxGetSelected(8,0); // else get the selected game
     RestoreGameSlot(savegameindex[index]);
    } // restore the game
  } // end Load GUI

  if (interface==9) { // if save interface
    string text;
    int index;
    if (button==0) { // if enter is pressed
      index=ListBoxGetNumItems(9,3);  // Count saved games
      if (index<20) { // if less than 20
        GetTextBoxText(9,0,text); // Get the typed text
        GUIOff(9); // Close interface
        SaveGameSlot(index+1,text);
      } // Save game (text as description)

      else { // if saved games are 20
        index=ListBoxGetSelected(9,3); // Get the selected save game
        GetTextBoxText(9,0,text); // Get the typed text
        InterfaceOff(9); // Close the interface
        SaveGameSlot(savegameindex[index],text);
      } // Overwrite the selected game
    }
  if (button==2) GUIOff(9); // if cancel is pressed close interface
  } // end Save GUI
}

Just paste this code over everything in those sections (except the lines that say // DO NOT EDIT OR REMOVE THIS LINE), I've left the Verb Coin scripting alone. Hopefully, it should now be working properly, and in the right game. :P
Title: Re: two gui questions
Post by: viktor on Thu 08/07/2004 08:11:29
Now this keeps poping up:
(http://www.2dadventure.com/ags/scripting_help.png)

and here is the script arpund line 194:
http://www.2dadventure.com/ags/scripting_help_2.png
Title: Re: two gui questions
Post by: Gilbert on Thu 08/07/2004 08:43:27
If you're using V2.61 onwards, try using the match brace function of the editor to make sure the braces were placed correctly, it's most likely this problem or a missing ;

/me is too sleepy to read at the moment.
Title: Re: two gui questions
Post by: viktor on Thu 08/07/2004 09:18:51
sorry i didn't understand what you meant with match brace.
Title: Re: two gui questions
Post by: Gilbert on Thu 08/07/2004 09:28:33
Put the cursor after a { then choose Edit --> match brace and see if the ending one is at the right position.

Actually I'd never used that before as I'm not using V2.61 yet.
Title: Re: two gui questions
Post by: viktor on Thu 08/07/2004 09:47:36
Ok ewerithing works. I didn't notice the smiley in the second part of the script. Insted of "8 )" there was a  8)

but now the quit gui won't work again. I'm going to try and solve it by myself. If I'll encounter any problems I'll just post here again.
Title: Re: two gui questions
Post by: viktor on Thu 08/07/2004 09:55:07
OK I solved all the problems. Thanks for the help you guys!  ;D