Hi all,
Here is a fragment of code from my global script. I
didn't write it :
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?
EDITHaha, 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!
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.