Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: sloppy on Thu 29/12/2005 15:49:58

Title: Extend display speech
Post by: sloppy on Thu 29/12/2005 15:49:58
Is it possible for speech to display for an extended period?  I have a character running across the screen the whole time yelling something, and I want the speech to stay the whole time.
Title: Re: Extend display speech
Post by: monkey0506 on Thu 29/12/2005 16:53:55
Quote from: The Manual--------------------------------------------------------------------------------

SayBackground
(Formerly known as DisplaySpeechBackground, which is now obsolete)

Overlay* Character.SayBackground(string message)

Similar to Say, except that this function returns immediately and the game continues while the character is talking. This allows you to have characters talking in the background while the player does other things. Note that the character's talking animation is not played if this function is used.
This command works by creating a text overlay with an automatic removal time delay. The overlay is returned by this command, so you can save it for use later with Overlay.IsValid and Overlay.Remove, if you want to remove the text prematurely.

If background speech is already on-screen for the character, it will be removed and replaced with the new MESSAGE.

All background speech is automatically removed when a normal Say command is used (unless you set the global variable game.bgspeech_stay_on_display to 1).

Example:

character[MAN].SayBackground("Hey, why won't you talk to me?");

will display the message above character MAN's head without pausing the game.
See Also: Character.Say



--------------------------------------------------------------------------------

Is this what you were looking for?

[EDIT:]

Also, if you want the talking animation to play, you might want to look at the QueuedSpeech module:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23806.msg294725#msg294725

I'd say use the BackgroundSpeech module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=24162.msg265420#msg265420), except it trashes the idle view delay, so if you have an idle view set then you might not want to use that.
Title: Re: Extend display speech
Post by: sloppy on Thu 29/12/2005 17:42:03
Yes, I'm using the SayBackground command.  But what I'm hoping for is to have the same speech display above the character for as long as I want, or as long as the character is moving. 

I guess I could have a long space between the last speech word and the closing quotation mark in the scripting.   That would keep the speech displayed longer.
But I was hoping there was a better way.
Title: Re: Extend display speech
Post by: monkey0506 on Thu 29/12/2005 19:31:35
Well...I'm trying to figure something out with repeatedly_execute_always, but the text blinks...I'm not sure if I can fix that...
Title: Re: Extend display speech
Post by: sloppy on Thu 29/12/2005 20:05:33
Blinking text may be better than nothing.  Could you show me how you're scripting that?
Title: Re: Extend display speech
Post by: monkey0506 on Fri 30/12/2005 03:36:40
It's on my other computer, actually in the form of a module at the moment.  Something that I have thought of since then, is perhaps if I call the Character.SayBackground function every time rep_ex_always runs instead of just when the text has been removed then maybe it won't blink.  Then again, maybe it will blink more.  Or there's the possibility that calling it that much will crash the game.  I can post my results tomorrow with the script that I'm using.
Title: Re: Extend display speech
Post by: monkey0506 on Sat 07/01/2006 05:37:14
Wow...sorry I kind of forgot about this.  Well, I finally got around to working with it, and I did get it to quit blinking.  When I get a chance, I'll make a page for it, but until then, you can download the PersistantSpeech module here (http://www.sitesled.com/members/meleepta/PersistantSpeech.rar).

You'll have to open the script header to find out what functions are implemented...oh...that might be confusing.  Seeing as I made it compatible with 2.7 & 2.71 (old & new style strings).  Just make note that if it's between "#ifdef AGS_NEW_STRINGS" and "#endif" then it's imported in 2.71 and later; if it's between "#ifndef AGS_NEW_STRINGS" and "#endif" then it's imported in 2.7.

And the fact that the Say function returns an Overlay* is misleading.  Because I call Character.SayBackground every time rep_ex_always runs, the Overlay is updated every time rep_ex_always runs...So to ensure that you have a proper Overlay*, do something like this:

// global script
Overlay* MyPersistantSpeechText;

// rep_ex_always
MyPersistantSpeechText = PersistantSpeech.GetOverlay();


That way the Overlay* will always point to a valid Overlay instead of a trashed one...

In the mean time, I'm trying to make it compatible with the QueuedSpeech module...or rather...make the QueuedSpeech module compatible with it.

[EDIT:]

Note that if you had any kind of talking animation playing, it won't be run...that's why I'm trying to make the two modules compatible with each other.