Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: BerserkerTails on Wed 03/12/2003 01:27:15

Title: Disabling ESC key
Post by: BerserkerTails on Wed 03/12/2003 01:27:15
Hey hey, it's everyone's favorite n00b with yet another easy technical question!

Is there any way to disable the ESC key in AGS? Not perminatley, mind you, but just for rooms where it's not needed. Here's the exact situation...

I use the ESC key to skip the opening cutscene, but then when actual gameplay starts, whenever the ESC key is pressed, it activated the Inventory GUI. Is there anyway I can disable the use of the ES key until another cutscene?
Title: Re:Disabling ESC key
Post by: Gilbert on Wed 03/12/2003 02:39:06
Just use a globalint to mark the situation whether the ESC key is disabled for bringing up the GUI or not.

Say, for definiteness I use globalint #5 and wants that by default, pressing ESC will bring up the GUI only when globalint 5 is zero and doesn't bring it up when it is non-zero.

Just find in the global script the on_key_press() function, there should be a line like (may differ in slight-detail in your codes):

if (keycode==27) GUIOn(Blah bla bla);

Just modify it to:

if ((keycode==27)&&(GetGlobalInt(5)==0)) GUIOn(Blah bla bla);



When you want to start a cutscene (or where you want it to be disabled), just add the following line before the StartCutscene(...) line:
SetGlobalInt(5,1);

When the cutscene ends (or whereever you want to reenable the GUI), just add the following line after the EndCutscene(...) line:
SetGlobalInt(5,0);
Title: Re:Disabling ESC key
Post by: BerserkerTails on Wed 03/12/2003 02:45:20
Thanks for the help Gilbot, but unfortunatley I didn't make myself perfectly clear  :-[

I meant that pressing the ESC button shouldn't bring up the GUI, but it does for some reason. Is there any way I can stop that from happening?
Title: Re:Disabling ESC key
Post by: Gilbert on Wed 03/12/2003 02:47:20
If you don't want that just comment out/delete the following line in the global script the on_key_press() function:

if (keycode==27) GUIOn(Blah bla bla);

Title: Re:Disabling ESC key
Post by: BerserkerTails on Wed 03/12/2003 02:49:28
Obviously... The tricky part, is that there is no (keycode==27) in the global script!
Title: Re:Disabling ESC key
Post by: Gilbert on Wed 03/12/2003 03:18:44
In that case, can you post the onkeypressed function content here?
Title: Re:Disabling ESC key
Post by: BerserkerTails on Wed 03/12/2003 03:45:02
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)   CentreGUI (2);
          GUIOff (1);
          GUIOn(2);  // 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

I can't see anything wrong with it...
Title: Re:Disabling ESC key
Post by: Gilbert on Wed 03/12/2003 04:00:12
The problem is here:

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) {
      CentreGUI (2);
      GUIOff (1);
      GUIOn(2); // 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
Title: Re:Disabling ESC key
Post by: BerserkerTails on Wed 03/12/2003 04:35:58
 ;D There we go!

Thanks a million Gilbot!