Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HillBilly on Sun 08/02/2004 18:59:24

Title: GUI pop up at ESC
Post by: HillBilly on Sun 08/02/2004 18:59:24
Right, I've been using the last HOUR on trying to figure out something that should be a easy code. I want that GUI 3 (MENU) to show up when you press ESC. I've tried if (keycode=27) GUIOn(3);, if (keycode == 27) { GUIOn(3);, on_key_press (int keycode 27) GUIOn(3);, on_key_press (int 27) GUIOn(3);, on_key_press (27) GUIOn(3); and I tried to combine these in all kinds of various way, but everything i try to test the game, it comes error messages. Usally something like
QuoteExpected ;
,
Quote*somethings wrong* keycode
and so on. Anybody know this code correctly?

God, I feel so stupid.  
Title: Re:GUI pop up at ESC
Post by: Barcik on Sun 08/02/2004 19:16:19
Have you tried the following.

on_key_press (int keycode) {
if (keycode == 27) GUIOn(3);}
Title: Re:GUI pop up at ESC
Post by: Ishmael on Sun 08/02/2004 19:26:07
I'd just add to the original on_key_press:

if (keycode==27) {
if (IsGUIOn(3)==0) GUIOn(3);
else GUIOff(3);
}

to make it toggleable with ESC
Title: Re:GUI pop up at ESC
Post by: HillBilly on Sun 08/02/2004 19:46:00
Quote from: TK on Sun 08/02/2004 19:26:07
I'd just add to the original on_key_press:

if (keycode==27) {
if (IsGUIOn(3)==0) GUIOn(3);
else GUIOff(3);
}

to make it toggleable with ESC

When i do that, i get the error I've got all night:

QuoteError (line 102): undefined symbol 'keycode'
Title: Re:GUI pop up at ESC
Post by: Dorcan on Sun 08/02/2004 19:56:20
function on_key_press(int keycode) {

  if (keycode==27) {
    if (IsGUIOn(3)==0) GUIOn(3);
    else GUIOff(3);
  }

}

If it still doesn't work, you must have made a syntax mistake somewhere else
Title: Re:GUI pop up at ESC
Post by: HillBilly on Sun 08/02/2004 20:03:58
Ah, there we go. Problem was i was inserting the code at the wrong place. I had to open "Global script" to edit it, not "edit script" in the GUI.