[SOLVED] Why can't I exit Pause?

Started by Monsieur OUXX, Wed 17/04/2013 12:11:59

Previous topic - Next topic

Monsieur OUXX

Hi all,

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

Code: AGS

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 :

  • I don't understand what is this half-baked "pause" triggered with weird shortcuts such as "Ctrl+C", etc. Could it be that it was originally something else (e.g. an "Exit" shortcut) and the developer removed some bits of the code?
  • When I use those shortcuts during the game, it pauses the game: The cursor disappears and everything is paused. However when I press them again it doesn't exit the pause. Am I missing something? Aren't shirtcuts like Ctrl+C ro Alt+Q also "system shortcuts" that make the window lose the focus or something? If not, can you imagine any reason why the pause wouldn't be interrupted?


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!
 

bush_monkey

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.

SMF spam blocked by CleanTalk