Jibble

Author Topic: on_key_press Return doesn't work in globalscript but does work in roomscript [so  (Read 127 times)

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
For some reason I fail to see why this is happening, so I hope someone here can explain this:

The roomscript code (as shown below) is working correctly: ENTER does load game.
(in this case the Global script has no (keycode == eKeyReturn) section in the on_key_press(eKeyCode keycode) function)

But:
The Global script code (as also shown below) is NOT working correctly: ENTER does NOT load the selected game.
(in this case the Room script has no (keycode == eKeyReturn) section in the on_key_press(eKeyCode keycode) function)

Room script:
Code: Adventure Game Studio
  1. function on_key_press(eKeyCode keycode)
  2. {
  3.   if (keycode == eKeyReturn)
  4.   {
  5.     if (gRestoreGame.Visible == true)
  6.     {
  7.       if (lstRestoreGamesList.SelectedIndex >= 0)
  8.       {
  9.         RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
  10.       }
  11.     }
  12.   }
  13. }

Global script:
Code: Adventure Game Studio
  1. function on_key_press(eKeyCode keycode)
  2. {
  3. ...
  4.   else if (keycode == eKeyReturn)
  5.   {
  6.     if (gRestoreGame.Visible == true)
  7.     {
  8.       if (lstRestoreGamesList.SelectedIndex >= 0)
  9.       {
  10.         RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
  11.       }
  12.     }
  13.   }
  14. ...
  15. }

EDIT:
darn, this was why:

Code: Adventure Game Studio
  1. else if (IsGamePaused() || !IsInterfaceEnabled())
  2.   {
  3.     keycode = 0;
  4.   }
« Last Edit: 23 Feb 2021, 18:17 by arj0n »

eri0o

Yeah, asking things here has the magic of helping to think for some reason. Happy it worked :)

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!