Keycode Problem

Started by Estaog, Wed 16/06/2004 09:40:35

Previous topic - Next topic

Estaog

I did this code in the global script so it will be like monkey island when you press f1 the quit gui comes up.But nothing seems to happen. Help?

if (b==0) keycode=0;
if (b==1) keycode=1;
if (keycode==359) GUIOn (1);
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Gilbert

Did you put it in the on_key_press() function?

strazer

What is the variable b for?

If it can only be either 0 or 1 then

  if (keycode==359) GUIOn (1);

would never be true since you reset the keycode variable in both instances.

Paper Carnival

or, if you really want to do it that way, try this instead:

if (keycode==359) GUIOn (1);
if (b==0) keycode=0;
if (b==1) keycode=1;

Estaog

I put this code in my Repeatedly execute part:
on_key_press (359) { GUIOn (1)}
And its saying unidentified token when saving, what is the deal?
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Barbarian

#5
Try putting under the part of the global script that has:

"function on_key_press(int keycode)"

And I tested to see if I could use my F1 key to open up my inventory GUI and it worked fine. I added the following command:

if (keycode==359) {GUIOn(INVENTORY);}

Ã,  Ã, You could probably do something similar to enable your GUI? Instead of using the specific GUI number (as I know that can change sometimes according to how you program things), use the GUI name instead perhaps, so regardless of the GUI number, the name of a GUI should still be associated with it. Well, either way should work fine I guess?Ã,  ;)

*Edit:  If you just want to bring up the default Quit GUI when you press the F1 key, then I think it would be:

if (keycode==359) {QuitGame(1); }
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

Estaog

Actually i did use that. But i did something that allowed you only to bring it up from room 2, removed it, and i still cant bring it up in room 1. It just flashes when i press f1. Any ideas?
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Radiant

Show us your code please? You probably didn't remove it properly, I'd guess

Estaog

function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==359) GUIOn (1);
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}

There used to be something that said if b==1 keycode=0, but removed it and its still flashing in room 1. I cant understand why. Maybe you know.
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Barbarian

Quote from: Tanker on Thu 17/06/2004 13:24:50
function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==359) GUIOn (1);
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
}

There used to be something that said if b==1 keycode=0, but removed it and its still flashing in room 1. I cant understand why. Maybe you know.

Well, looking at the global script from a freshly started new game, that part of the code looks like:

function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==17)Ã,  QuitGame(1);Ã,  Ã, // Ctrl-Q
Ã,  if (keycode==363) SaveGameDialog();Ã,  Ã, // F5
Ã,  if (keycode==365) RestoreGameDialog();Ã,  // F7
Ã,  if (keycode==367) RestartGame();Ã,  // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==9)Ã,  Ã, show_inventory_window();Ã,  // Tab, show inventory

Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
}


Ã,  Ã, So, maybe just use that, but instead of Ctrl-Q for quitting the game: if (keycode==17)Ã,  QuitGame(1);
...change it to: if (keycode==359) QuitGame(1);
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

Estaog

Quote from: Barbarian on Thu 17/06/2004 13:53:22
Ã,  Ã, So, maybe just use that, but instead of Ctrl-Q for quitting the game: if (keycode==17)Ã,  QuitGame(1);
...change it to: if (keycode==359) QuitGame(1);

You mean change it to (keycode==359) GuiOn(1);
Right?
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Scorpiorus

Yes, put GuiOn(1) instead and see if it works.

Estaog

Nope it still flashes!
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

Scorpiorus

What do you mean by 'flashes', does the GUI come up and then quickly disappear?

Radiant

Maybe your GUI is being turned off somewhere else?
Are you doing this:

Code: ags

if (IsGUIOn (1) == 0) {
  if (keycode == 42) GUIOn (1);
}

if (IsGUIOn (1) == 1) {
  if (keycode == 42) GUIOff (1);
}


See what I mean? It may be the case that the same key turns the GUI back off?

Estaog

Quote from: Scorpiorus on Fri 18/06/2004 14:11:56
What do you mean by 'flashes', does the GUI come up and then quickly disappear?

Yes thats what it does.

But then how come it onlyh flashes in that room?
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

SSH

Check that room script... you probably have a GUIOFF in your repeatedly execute when you meant for it to be in the before fadein interaction...
12

Estaog

PlayMusic (1);
GUIOff (1); 
GUIOff (0); <= (:o)
if (cut==3) {
  ObjectOn (0);
  ObjectOn (1);

Why watever do you mean?  ::)
;)
Think about the kittens man!

http://members.aol.com/johnk0/godkills.jpg

SMF spam blocked by CleanTalk