on_key_press Return doesn't work in globalscript but does work in roomscript [so

Started by arj0n, Tue 23/02/2021 18:13:54

Previous topic - Next topic

arj0n

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: ags
function on_key_press(eKeyCode keycode)
{
  if (keycode == eKeyReturn)
  {
    if (gRestoreGame.Visible == true) 
    {
      if (lstRestoreGamesList.SelectedIndex >= 0)
      {
        RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
      }
    }
  }
}


Global script:
Code: ags
function on_key_press(eKeyCode keycode)
{
...
  else if (keycode == eKeyReturn)
  {
    if (gRestoreGame.Visible == true)
    {
      if (lstRestoreGamesList.SelectedIndex >= 0)
      {
        RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
      }
    }
  }
...
}


EDIT:
darn, this was why:

Code: ags

else if (IsGamePaused() || !IsInterfaceEnabled())
  {
    keycode = 0;
  }

eri0o

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

arj0n


SMF spam blocked by CleanTalk