Disabling Key Functions [SOLVED]

Started by Atelier, Sun 10/05/2009 18:03:40

Previous topic - Next topic

Atelier

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?

Trent R

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:
Code: ags

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Atelier

#2
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?

Khris

In the global on_key_press, add this line at the top of the function:

Code: ags
  if (player.Room == 5) return;    // disable all key presses in room 5

Atelier

Now I don't have to type out all of the keys.  :) Thanks!

SMF spam blocked by CleanTalk