Creating a Blocking Function (e.g mimicing Display) [Solved with cheats]

Started by magintz, Mon 09/03/2009 22:45:19

Previous topic - Next topic

magintz

I'm trying to create a function that acts in a similar way that Character.Say(String msg) or Display(String msg) where the function will not end and continue on to the next line of code until a pre-determined amount of time or the user presses a mouse button.

For instance I have created a function called Speak which can be called to display player speech in a custom GUI, calling it for instance:

Code: ags

player.Speak("My name is Player 1");
player.Speak("I live on the moon.");

...

function Speak(this Character*,String msg) {
  lblSpeech.Text=msg;
}


However because the function terminates at the end and continues onto the next line the only message that is displayed is "I live on the moon".  I could really use some assistance in getting this working, I've tried to create a while loop that waits for a mouse click (when a mouse button is clicked flip a boolean value to true which signals the while loop to break) however this results in an infinite loop causing AGS to crash.

Thanks in advance,
Maggi :D
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

GarageGothic

#1
What I did when I wrote my similar custom speech display function was to cheat and use Character.Say for the timings and for animating the character. I would display the spoken text on the GUI, then use Character.Say (which is blocking) with the same text and once that returned I removed the text on the GUI again. To avoid the Character.Say displaying anything I imported an empty font file, but I think it can also be done by setting text color to RGB(255,0,255).

magintz

#2
Genius cheat ^_^

Do you happen to have that font at hand you could send to me?
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

GarageGothic


magintz

#4
Quote from: GarageGothic on Mon 09/03/2009 23:20:53
Sure, just pm me your email address.

Thanks, I just whipped one up in Radiant's font editor, but I seem to be having problems with the way the speech is coming out.

I've got the Speech Style set to Sierra style. I'm using my invisible font.

The problem I'm having is that the portrait is being displayed for the sierra style speech (My speech GUI uses the players SpeechView which makes things easy for my portraits so would rather not change) and the player.Say is blocking MY speech so my GUI is greyed out while player.Say is running which makes everything look horrible (I have greyed out when disabled checked but would like to keep it that way).
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

GarageGothic

Can't really help you circumvent the greyed-out-when-disabled thing if you want to keep it like that (turning it off during dialog is not an option?). But perhaps you could use an overlay instead of a GUI  to display your text?

magintz

I've cheated once again.

To fix the greyed out problem I've create a second button over the top which I make visible (this has a greyed out graphic).

To fix the portrait being displayed but keeping the player.Speak function using the SpeechView I'm now getting the view from the thinking view.

Everything works and looks right just the way it should, thanks for the help.
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

Trent R

SetGameOption(option, int value)
OPT_WHENGUIDISABLED 
When GUI is disabled, 0=grey out, 1=go black, 2=unchanged, 3=turn off



~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Dualnames

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)

SMF spam blocked by CleanTalk