Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Monsieur OUXX on Wed 17/04/2013 12:11:59

Title: [SOLVED] Why can't I exit Pause?
Post by: Monsieur OUXX on Wed 17/04/2013 12:11:59
Hi all,

Here is a fragment of code from my global script. I didn't write it :

Code (AGS) Select

function on_key_press(int keycode) {
     
  if (IsGamePaused() == 1) {
    keycode=0; // game paused, so don't react to keypresses
  }
 
  if ((   keycode==eKeyCtrlQ )
      || (keycode==317)//ALT-Q
      || (keycode==eKeyCtrlC ))
  { 
    if (IsGamePaused()==0) {
      PauseGame();
      DisableInterface();
      Mouse.Visible = false;
    } else {
      UnPauseGame();
      EnableInterface();
      Mouse.Visible = true;
    }
  }

  ...
}




I have two questions :


EDIT
Haha, silly me. That chopped-down version of the function put the answer right in my face: When the game is paused, keystrokes are dumped by the very first "if"...
Solved!
Title: Re: [SOLVED] Why can't I exit Pause?
Post by: bush_monkey on Wed 17/04/2013 14:29:44
The first check resets your key code variable to 0 so when it goes on to do the second check,  your key code is not equal to any of the combinations listed.