Display command

Started by brushfe, Thu 08/03/2007 23:38:17

Previous topic - Next topic

brushfe

Does anyone know if there's a way to have a Display command resolve ONLY after pressing the enter key?

My specfic situation is i'm using a game using the Space Quest 2 template, and when the game displays a message while the user is typing a command like "look wall" the message disappears because they're typing. The ideal situation would be that when a message pops up while you're typing, it would stay there until you press ENTER.

Any thoughts/help is appreciated!

Ashen

#1
This thread is still on the first page of the tech forum - check Lt. Smash's fourth suggestion, and mine and Gilbot's replies.

EDIT:
Oops, I thought at least one of us had linked to the Global variables page of the manual - obviously you found it for yourself, though. game.skip_display is what I meant to point you towards, honest...
I know what you're thinking ... Don't think that.

brushfe


Thanks, and forgive the hasty post!

it seems then that game.skip_display is more what i'm after, since i want to modify display commands, as opposed to speech.

Thanks again

brushfe


I've finally gotten the chance to try the game.skip_display function out, but it isn't really what I was looking for... its modes are restricted to combinations of mouse/keyboard.

Is there a way to customize this further? As in, a display message ONLY goes away when you press ENTER? (as opposed to anything on the keyboard)

Ashen

Urgh, I don't know where my head was the other day...

I thought game.skip_display was equivalet to skip_speech_specific_key - but you're right, it isn't, which means my post was absolutly no use. Sorry about that, and I think it also means there's no easy way to do what you want after all.

Setting game.skip_display to 2 or 4 (no skipping, or mouse only) will mean the message won't be skipped, but also that the player will have to stop typing untill they've read the message. Short of scripting your own Display replacement, I think that's the best you can do for now. (Unless the SQ2 template has already done this? It just looks to use the standard one, though.)
I know what you're thinking ... Don't think that.

brushfe


Haha.. Thanks for the help anyway! Maybe in the next version. I'll make an attempt at a custom display command (which means i'm sure we'll meet again in the technical questions forum.)

Until there's a game.skip_display_specific_key,
brushfe

Ashen

#6
I've done it this way, and it works fine:

1. Make your GUI. I've just given mine a white background and a black border - just like the default Display appearance. It's called 'DISPLAY', it's Popup Modal, and has a Label on it (lblDisp) at 5,5. The GUI position and sizing, etc, doesn't matter as it'll be set in script.

2. The function:
Code: ags

int gameloops;
function Show(String Message) {
  if (game.skip_display != 3) gameloops = ((Message.Length / game.text_speed) + 1)*GetGameSpeed();
  else gameloops = -1;
  // If Display-ed text should time out, sets the delay.
  lblDisp.Text = Message;
  lblDisp.Width = GetTextWidth(Message, lblDisp.Font) + 1;
  if (lblDisp.Width > 150) lblDisp.Width = 150; // Limits GUI size to about half the width of the screen - raise or lower this as you like.
  lblDisp.Height = GetTextHeight(Message, lblDisp.Font, lblDisp.Width);
  gDisplay.Width = lblDisp.Width + 5;
  gDisplay.Height = lblDisp.Height + 5; // Change the '+5's to increase right and bottom borders
  gDisplay.Centre();
  gDisplay.Visible = true;	
}


Also add an import line to the Global Header, so you can use the function anywhere:
Code: ags

import function Show(String Message);


3. If you haven't got one already, make a repeatedly_execute_always function in the Global Script, and add this:
Code: ags

  if (IsKeyPressed(13)) gameloops = 0; // 13 = Enter, change this to change the key used
  if (gameloops > 0) gameloops --;
  else if (gameloops == 0)	{
    gDisplay.Visible = false;
    gameloops = -1;
}


And you should be done.
I know what you're thinking ... Don't think that.

brushfe

wow, thanks a lot man! a great help. i'll do my best to incorporate it into the sq2 template, finnicky as it is!

SMF spam blocked by CleanTalk