Problems with background dialog (SOLVED)

Started by Matti, Sun 03/02/2008 18:17:54

Previous topic - Next topic

Matti

Immediately after a dialog between the main character and another person I want that person to have a short dialog with another one. In the dialog editor I used the start-script function to set a certain variable to true. Then, in the room script's repeatedly execute section I scripted the dialog (with several say.background commands) if the variable is set true.

Problem is: Both characters just say their last phrases.

If I put a wait command between the phrases, it says there's a blocking command within the repeatedly execute section. But I don't want that anyway cause the main character should be free to do whatever one wants while this dialog appears in the background. What do I have to do to let all sentences appear one after another. And is there a better way than putting the dialog into the rep.-exec.-section? cause it should just happen once, so there's no need to check it all the time.



EDIT: I solved it now in a complicated way. Just set a timer and scripted like this:

Code: ags

  if (lucyannatalk==true){
    lucyannatimer=lucyannatimer+1;

    if (lucyannatimer==50) cLucy.SayBackground("");
    if (lucyannatimer==150) cAnna.SayBackground("");
    if (lucyannatimer==200) cLucy.SayBackground("");    
    ..
    ..
    ..
    if (lucyannatimer==800) lucyannatalk=false;
  }


I had to try a bit around to get the timing of the phrases right. How can I script, that the phrases just come one after another in normal timing. Has the overlay-function to do with that?

Khris

Character.SayBackground returns the created overlay.
AGS will use its standard formula to calculate how long it's going to be visible, then delete the overlay.
So you can check if the overlay became invalid, then display the next sentence.

pseudocode:
Code: ags
Overlay bgspeech;

...
  if (!bgspeech.IsValid) bgspeech = cLucy.SayBackground("");
  ...

So instead of counting frames, increment the var after the overlay stopped being valid, then call the next SayBackground.

Matti

#2
An error message occures:

'.IsValid' is not a public member of 'Overlay'. Are you sure you spelt it correctly (remember, capital letters are important)?

Don't know how to deal with that..


Okay, now I got it working. Had to change .IsValid to .Valid. This is my script now:

Code: ags

  if (lucyannatalk==true){
    
    if (lucyannaspeech==null) lucyannaspeech = cLucy.SayBackground("");
    
    if (!lucyannaspeech.Valid)lucyannatimer=lucyannatimer+1;
    
    if ((lucyannatimer==2)&&(!lucyannaspeech.Valid)) lucyannaspeech = cAnna.SayBackground("");
    if ((lucyannatimer==3)&&(!lucyannaspeech.Valid)) lucyannaspeech = cLucy.SayBackground("");
    if ((lucyannatimer==4)&&(!lucyannaspeech.Valid)) lucyannaspeech = cAnna.SayBackground("");
    if ((lucyannatimer==5)&&(!lucyannaspeech.Valid)) lucyannaspeech = cLucy.SayBackground("");

  if (lucyannatimer == 10) lucyannatalk=false;
  }


Thanks, KhrisMuc.

Khris

Right, sorry, it still says "IsValid" in the manual entry for SayBackground, didn't bother to check the Overlay entry.

SMF spam blocked by CleanTalk