Disabling ESC key

Started by BerserkerTails, Wed 03/12/2003 01:27:15

Previous topic - Next topic

BerserkerTails

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?
I make music.

Gilbert

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);

BerserkerTails

#2
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?
I make music.

Gilbert

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);


BerserkerTails

Obviously... The tricky part, is that there is no (keycode==27) in the global script!
I make music.

Gilbert

In that case, can you post the onkeypressed function content here?

BerserkerTails

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...
I make music.

Gilbert

#7
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

BerserkerTails

 ;D There we go!

Thanks a million Gilbot!
I make music.

SMF spam blocked by CleanTalk