Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Atelier on Sun 10/05/2009 18:03:40

Title: Disabling Key Functions [SOLVED]
Post by: Atelier on Sun 10/05/2009 18:03:40
Hullo.

I was wondering how you would go about disabling all key presses in certain rooms. For example, my menu (Room 0) shows the GUIs when I press the keyboard shortcuts, but I don't want them to. Then, I want to enable all of the shortcuts again when the player enters the first room (Room 1). Any suggestions?
Title: Re: Disabling Key Functions
Post by: Trent R on Sun 10/05/2009 18:07:44
Check out ClaimEvent in the manual.

Based off of your other thread (which you could've posted this question in, since it's the same topic) you should put a code something like this in your room script:
function on_key_press (eKeyCode keycode) {
 
   if (keycode == eKeySpace) ClaimEvent();
}


(sorry there's not much of an explanation. I'll return later, or just wait for someone else to reply)

~Trent
Title: Re: Disabling Key Functions
Post by: Atelier on Sun 10/05/2009 18:25:16
Thank you very much, I've got it working fine. I thought about putting it in my original thread, but wasn't quite sure what to do so I made a new one. I'll try and stop over-posting the forums from now on  :) Thanks!

EDIT: Is there any way to enter all the key codes in the same if function? Or do you have to type them all in separately like this?
Title: Re: Disabling Key Functions
Post by: Khris on Sun 10/05/2009 19:01:29
In the global on_key_press, add this line at the top of the function:

  if (player.Room == 5) return;    // disable all key presses in room 5
Title: Re: Disabling Key Functions
Post by: Atelier on Sun 10/05/2009 19:19:21
Now I don't have to type out all of the keys.  :) Thanks!