Display messages while on inventory gui. (solved)

Started by Baro, Mon 07/07/2008 16:04:21

Previous topic - Next topic

Baro

I'm making an inventory GUI in the style of Sam&Max Hit the Road or Monkey Island 3. The gui is set as pop up modal. How do I display speech-style messages like in Monkey island 3 when you looked, etc at items? Whenever I use the say function the gui turns off and the game freezes while the character starts to speak, and when I use display, if display text as speech is on, it happens the same as say, and if it's off, the message is shown in the so-called "standard message box", which I don't know how to edit.
I want the message as if the main character was saying it. How do I do this?

Akatosh

This should do the trick:

Code: ags

//Put this in your inventory item's "look" interaction

gInventory.Visible=false; //The name of your inventory GUI
//If there are any other GUIs visible, too, repeat for them
Wait(1);
player.Say("It's a key!"); //The speech you want to be displayed
gInventory.Visible=true;

Baro

Quote from: Akatosh on Mon 07/07/2008 16:55:08
This should do the trick:

Code: ags

//Put this in your inventory item's "look" interaction

gInventory.Visible=false; //The name of your inventory GUI
//If there are any other GUIs visible, too, repeat for them
Wait(1);
player.Say("It's a key!"); //The speech you want to be displayed
gInventory.Visible=true;

With that code, the inventory is not visible while the character is speaking.
Using saybackground and without the wait(1), the gui doesn't even blink - but now the text is visible only if the player is on certain parts of the screen so the text (lucasArts style) is not behind the inventory background.
Is there any combination of saybackground and sayat?

Mazoliin

You could do this:

Set up a transparent gui with a label on it, and name the label something suitable.
Code: ags

//In the script header
import function LookInv(String invlook);

//In top of the global script
function LookInv(String invlook){
  lblSayInv.Text = "%s", invlook;
  gSayInv.Visible = true;
  SetTimer(1, ((invlook.Length/game.text_speed) + 1)*GetGameSpeed());
}

//repeatedly execute always
if (gSayInv.Visible == true){
  if (IsTimerExpired(1)){
    gSayInv.Visible = false;
  }
}

//In the "look" interaction of the inventory item
LookInv("Hey, this is what will be displayed");


But make sure that the labels gui has a higer Z than the inventory, so it will be placed in front of it.

Baro

#4
Quote from: Mazoliin on Mon 07/07/2008 20:19:20
You could do this:

Set up a transparent gui with a label on it, and name the label something suitable.
Code: ags

//In the script header
import function LookInv(String invlook);

//In top of the global script
function LookInv(String invlook){
  lblSayInv.Text = "%s", invlook;
  gSayInv.Visible = true;
  SetTimer(1, ((invlook.Length/game.text_speed) + 1)*GetGameSpeed());
}

//repeatedly execute always
if (gSayInv.Visible == true){
  if (IsTimerExpired(1)){
    gSayInv.Visible = false;
  }
}

//In the "look" interaction of the inventory item
LookInv("Hey, this is what will be displayed");

But make sure that the labels gui has a higer Z than the inventory, so it will be placed in front of it.

While you were posting that, I got a similar idea. Made a transparent label control that uses speech font in the inventory guy, then made this function
Code: ags
function SayInventory (String message){
        SayLabel.Text = message;
        invsaytimer = 0;
        invsaytimermax = (message.Length * 4);
        }

(where invsaytimer and invsaytimermax are global ints)
invsaytimermax = (message.Length * 4) because approximattely I chronometred 1 second for 10 characters in a display command, but I'll try to use a timer as Mazoliin sugested.

then in repeatedly_execute, a timer

Code: ags
  if (SayLabel.Text != "")
      if (invsaytimer == invsaytimermax) {
        SayInventory("");
        }
      else {
      invsaytimer++;
  }


Just pasting here because it seems to work all fine. Then everytime I want a message to be displayed while on the inventory window, SayInventory (text_to_say).

Thanks everyone.

SMF spam blocked by CleanTalk