Scorpiorus ' DisplaySpeechBackground Code [ABANDONED]

Started by Mr Flibble, Tue 21/12/2004 18:52:42

Previous topic - Next topic

Mr Flibble

I'd been having trouble with the standard DisplaySpeechBackground, so I came over to the boards, searched, and found this.
It seemed to be an ideal solution. So I copied and pasted the code into AGS, but the script won't compile properly.
I think the problem may lie within version differences between my game and scorp's code. To the best of my knowledge, I use ver 2.61.
These are some of the errors I get.
"ERROR line 25 Undefined token "DisplaySpeechQ_RE();"
This is from re.exec, and the code is:
Code: ags

function repeatedly_execute() { 
  // put anything you want to happen every game cycle here
  DisplaySpeechQ_RE()

}

When I delete that piece of code, for arguments sake, I get this error.
"Line already referenced as import"

Code: ags

function qStopSpeech() {
   if (qIsTalking()) {
      qStopSpeechChannel();
      RemoveOverlay(cur_overlay);
      int i = mod(cur_say, BUFFER_SIZE);
      int CharID = Buffer[ i ].CharID;
      ReleaseCharacterView(CharID);
      if (prev_char > -1) { ReleaseCharacterView(prev_char); prev_char = -1; }
      stop_talk = 0;
      cur_say = cur_str;
   }
}

Though I doubt the two are related. When I deleted THIS piece of code, I got a message saying certain code didn't add up properly, and the game crashed. Though It DID compile.
I did attempt to fix this myself, but since I didn't write the code, I have a limited understanding of how it works.
Ah! There is no emoticon for what I'm feeling!

Scorpiorus

Quote from: Mr Flibble on Tue 21/12/2004 18:52:42These are some of the errors I get.
"ERROR line 25 Undefined token "DisplaySpeechQ_RE();"
This can happen if you pasted the code after the repeatedly_execute function. You need to paste Main global script part right at the top of the main global script. Let me know if it works. ;)

Mr Flibble

Thanks, that fixed it.
Having said that, I haven't converted my novella sized chain of DisplaySpeechBackgound() to your functions yet, but since it compiled so nicely, I expect no problems.

Thats a really dandy piece of script you know. It should be in the contribution thread or the BFAQ or something.
Ah! There is no emoticon for what I'm feeling!

Scorpiorus

No problem, glad you sorted it out. :)

But make sure you have DisplaySpeechQ_RE() within repeatedly_execute, otherwise the script won't work!

QuoteThats a really dandy piece of script you know. It should be in the contribution thread or the BFAQ or something.
Thanks, and it's in the Technical Archive forum and we usually have all scripts/tricks/workarounds/technical solutions collected there.

Mr Flibble

Actually, I do have one problem, though its not with the template.
The background speech is a guy on on the phone.
So I have
Code: ags
qDisplaySpeech(MAN, "Blah blah blah");
qDisplaySpeech(MAN, "Blah blah blah");
qDisplaySpeech(MAN, "Blah blah blah");
qDisplaySpeech(MAN, "Blah blah blah"); 

etc.
But when the player pulls the phone wire out of the wall, want the bg speech to stop.
So I declared, at the top of my room script,
int telephone = 5;
Then made
Code: ags

if (telephone==5) {
   qDisplaySpeech(Man, "Blah");
  }
else {
        qStopSpeech();

And I put this around every line in my pretty long speech.
I reckoned that this would check if my variable was at 5 or not before saying every line, butit didn't.
Then on the interaction for pulling out the cord, set
telephone =10; and I know it changed, because I put in a text display to check if it did or not.
But this didn't work, and the bg speech continued.
So I changed it to
Code: ags

while (telephone==5) {
     qDisplaySpeech(MAN, "Balh"); 

But that didn't work either. Should it perhaps have been
while ((telephone==5)==1) { ?
Anyway, any help would be appreciated. I know of RemoveOverlay, but it asks for an ID, and I don't know where that gets defined. And even then, that wouldn't stop the speech.
Ah! There is no emoticon for what I'm feeling!

Scorpiorus

#5
Ah, I see what you're after. But where did you put "qDisplaySpeech(...);" lines?

Try something like:

int telephone = 1;

player enters room:

if (telephone == 1)
{
  qDisplaySpeech(MAN, "Blah blah blah");
  qDisplaySpeech(MAN, "Blah blah blah");
  qDisplaySpeech(MAN, "Blah blah blah");
  qDisplaySpeech(MAN, "Blah blah blah");
}

player pulls a wire out (interact object or something):

qStopSpeech();
telephone = 0;

How did it turn out?

Mr Flibble

No, didn't work. He keeps on talking.
Thats actually what I had more or less, but I did retry, but no luck.
I tried using while(telephone==1); but that just locked up that game.
I even tried creating a new set of lines for him to say, but he continued his phone conversation first.
Ah! There is no emoticon for what I'm feeling!

Scorpiorus

I just tried and it worked fine for me.

Check the qStopSpeech function in the global script, is it ok?

What do you have in the global and this room scripts?

Mr Flibble

I'm sure I'll need to resolve this in the future, but right now, its no longer an issue.
It was for a Christmas game you see, so I just edited the background speech to be shorter, and made the guy animate in the background.

I'm sure either me, or someone, will dredge this one day in search of actual answers.
Ah! There is no emoticon for what I'm feeling!

SMF spam blocked by CleanTalk