Disable the keyboard for every room

Started by steptoe, Sat 26/11/2011 06:58:02

Previous topic - Next topic

steptoe

Hi

I am trying to disable the keyboard for every room.

The below code in each room works but does not stop Alt + x, though it does disable Esc, F save, F Load etc.

In each Room I have:

Code: ags

function on_key_press(eKeyCode k) {

  // kill all keyboard functionality
  ClaimEvent();
}


Even tried this Top of Global:

Code: ags

bool kb_on = true;


and with this in Global:

Code: ags

function on_key_press(eKeyCode keycode)

{
  if (!kb_on)   // and with if (kb_on)
  {
    ClaimEvent();
    return;


Can you help?

Cheers




It's not over until the fat lady sings..

Snarky

You can't disable Alt-X. It's built into the engine as a failsafe so that it's always possible to quit in case your game locks up.

Dualnames

QuoteThe keycode for Abort Game, which allows the you to quit even if your script is stuck. Default 324 (Alt+X).

So if you disable it then if you game gets stuck, people have to use alt ctrl delete or some other way.

Apart from pointing that, your code seems to work, though just keeping all the stuff on a global script or a module script and having only one instance of the on_key_press function is definitely the way I would go. Just a global boolean variable and on instance of keypress.

Code: ags

function on_key_press(eKeyCode keycode)
{
  if (kb_on)  
  {
//rest of script ecc inside the if
  }
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

Or

Code: ags
  if (!kb_on) return;   // exit the function


You can disable Alt-X by changing the value of game.abort_key.
If you do that though, please mention it when you publish the game so people know not to download it.

monkey0506

For maximum troll points, set game.abort_key to -1, completely disabling it.

steptoe

Hi

thanks for your answers guys.   

It was more of a quest to find an answer than to actually use it so no total Troll points monkey  ;D

It is fine as it is with alt + x to quit.

I do have a visual Quit option available during the game.

Thanks again.




It's not over until the fat lady sings..

monkey0506

The benefit of the abort key is that it is still functional even when other interface items (such as keypresses and button clicks) may not be. You can change the abort key if you want, but document it clearly if you do so. Disabling it completely is just stupid (unless it's an Oceanspirit Dennis game).

I'm aware you said already that you're not planning to disable it, but Khris' comment may have come across the wrong way, so I wanted to clarify that as long as you make it known what the abort key is you should still be fine (even if you do choose to change it for some reason).

Khris

Yeah, I just wanted to express how stupid I find it to take away the only failsafe for a hanging game. This is were I think the line between design choices and being a control freak is crossed.

I briefly considered to post something along the lines of "if you don't know how to disable it, you probably shouldn't do it in the first place".

steptoe

Khris:

It was a thought I had, but opted out for fail-safe reasons as mentioned (after consideration).

I overlooked Abort because I was looking at 407(Alt) + X.

In game design you do need an exit, period. I do have an exit sign visible and of course good old Alt + X is available as well.

I appreciate your words of wisdom for future reference.

Monkey:

Likewise as with Khris, thanks.

OSP: How to script crap in the best possible way.

Don't steal any crap ideas from us minor urchins :D

Thanks guys

It's not over until the fat lady sings..

Gilbert

Quote from: Khris on Sat 26/11/2011 21:59:20
Yeah, I just wanted to express how stupid I find it to take away the only failsafe for a hanging game.
Shouldn't Ctrl-Alt-End always work? It doesn't help if the player is not familiar with AGS or didn't read the game's documents even if it's mentioned.

SMF spam blocked by CleanTalk