Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheRoger on Sun 02/10/2011 08:48:02

Title: Continue after dialog
Post by: TheRoger on Sun 02/10/2011 08:48:02
It seems that I have an issue with dialog. I tried search, but I didn't get correct keywords I guess, so here it goes:


cKataya.Say("text1");
dDialog1.Start();
cKataya.Say("text2")


So the problem is, that dialog starts after text2 and I want it between text1 and text2. What I must do to solve this?
Title: Re: Continue after dialog
Post by: steptoe on Sun 02/10/2011 09:13:52
Have you used a Name for dDialog1.. I assume you may get an error message if dDialog1 does not exist.

Title: Re: Continue after dialog
Post by: TheRoger on Sun 02/10/2011 10:30:25
It exists, I just didn't named it.


@S 
return
@1
stop
@2
stop
@3
stop


Three options, but gives same answer and continues cutscene.
Title: Re: Continue after dialog
Post by: David Ostman on Sun 02/10/2011 11:43:41
Dialogs always execute last in a function, so that won't work.

You can try just executing a dialog with all you need in it, if you want. This might be a bit of an ugly solution, but it should work.

@S
 cKataya.Say("text1");
return
@1
 cKataya.Say("text2");
stop
@2
 cKataya.Say("text2");
stop
@3
 cKataya.Say("text2");
stop


That will start with Kataya saying text1, then you get the dialog options, and whatever you choose she will say text2 and exit out of the dialog. Perhaps not the cleanest way, but it should work.

EDIT: By the way, you don't need to use Say in the dialogs, you can do it the normal way, but that's my own preferred way of doing it :)
Title: Re: Continue after dialog
Post by: Khris on Sun 02/10/2011 12:07:51
Yes, if there's more commands, just put whatever is supposed to happen after the dialog in a function and call that before exiting the dialog.

This is really the only thing I don't like about 3.x; in earlier versions you'd simply add a second RunScript action to the event and put your code in there. Maybe at some point we can put something like this in the event line: "cGuy_Talkto(), cGuy_Talkto2()"
Title: Re: Continue after dialog
Post by: TheRoger on Sun 02/10/2011 13:45:36
Thank you for help, I did it David's way (and it worked), but that was most inconvenient, especially if dialog is very long with lots of player answers.
Title: Re: Continue after dialog
Post by: David Ostman on Sun 02/10/2011 16:43:02
Yeah, tell me about it. I have a long "epic" interactive cutscene where you jump from dialog to walking around automatically to dialog, about 17 times. If someone comes up with an easier way, or a module of some kind for this kind of thing, there's a lot of good karma points to be had :P
Title: Re: Continue after dialog
Post by: Khris on Sun 02/10/2011 18:04:51
It should be possible to catch the moment immediately after a dialog, usually they suspend repeatedly_execute so that could be used.
Then one uses a variable to run some code.

  RunAfterDialog(1);
  dDialog.Start();


RunAfterDialog simply sets a global variable to 1 and inside repeatedly_execute, code determines if the game just finished a dialog and calls AfterDialog(1);
Title: Re: Continue after dialog
Post by: pcj on Sun 02/10/2011 19:28:17
You can also CallRoomScript() at the end of a dialog script for a more straightforward way.
Title: Re: Continue after dialog
Post by: monkey0506 on Sun 02/10/2011 20:19:41
It would be possible for a module to provide a Dialog.IsScriptFinished function using the custom rendering options, the dialog_options_render function for the in-dialog update loop, the DialogOptionsRenderingInfo.DialogToRender property to compare the most recently run dialog against the extender method's this pointer, and the repeatedly_execute function to check for the return of the normal script loop, to expand on what Khris said.

You could then check said function in your own repeatedly_execute to perform the "after dialog" events. You could of course write a custom function for more elaborate cases, but the basic gist would be the same, and vastly simplified for the end-user.

I could take a look into it Tuesday when I'm off.
Title: Re: Continue after dialog
Post by: Khris on Sun 02/10/2011 20:27:04
Quote from: pcj on Sun 02/10/2011 19:28:17
You can also CallRoomScript() at the end of a dialog script for a more straightforward way.
Regardless of what you call, the point of my post was showing a way that avoids having to put the same call multiple times in every dialog script.
Title: Re: Continue after dialog
Post by: Arjunaz78 on Mon 03/10/2011 21:32:12
Quote from: LeKhris on Sun 02/10/2011 18:04:51
It should be possible to catch the moment immediately after a dialog, usually they suspend repeatedly_execute so that could be used.
Then one uses a variable to run some code.

  RunAfterDialog(1);
  dDialog.Start();


RunAfterDialog simply sets a global variable to 1 and inside repeatedly_execute, code determines if the game just finished a dialog and calls AfterDialog(1);

Sorry for asking noob question..is it i can use a 'RunAfterDialog(1);' and then call another event or function like...

function room_AfterFadeIn()
{
RunAfterDialog(1);
  cEgo.FollowCharacter(cEgo, 10, 97);
}


OR

function Window_Look()
{
  RunAfterDialog(1);
    aBeach.Play();
      player.Walk(116,  165, eBlock);
        aBeach.Stop();
  Display ("It's just a window.");
}


Is it i must put and add something or i just miss something?
and how to use and set the code to be call the function from different script (Global script and Room Script)?
Title: Re: Continue after dialog
Post by: Khris on Mon 03/10/2011 22:17:29
This wasn't a full solution, RunAfterDialog isn't an official command, I just made that up.

Here's a messy implementation:

Put this DIRECTLY ABOVE the repeatedly_execute function in the global script:

bool old_iie = true, do_rad;
void repeatedly_execute_always() {
  bool iie = IsInterfaceEnabled();
  if (iie && !old_iie) do_rad = true;
  old_iie = iie;
}

int rad;
void RunAfterDialog(int p) {
  rad = p;
}


Put this INSIDE the repeatedly_execute function in the global script:

  if (do_rad) {
    do_rad = false;
    on_after_dialog(rad);
  }


Add this line to the global header:

import void RunAfterDialog(int p);

Now add this function to the global script, again anywhere ABOVE repeatedly_execute. In here you're going to put the code supposed to be called after a dialog.

function on_after_dialog(int p) {

  if (p == 1) {
    Display("Bam.");
  }
}


Now call RunAfterDialog(1); immediately before the Dialog.Start command, and AGS will display "Bam." as soon as the player exits the dialog.

So, Arjunaz78, you are not supposed to call this on its own; ONLY RIGHT BEFORE Dialog.Start():

function cGuy_Talk() {

  RunAfterDialog(1);
  dDialog0.Start();
}


Again, this whole thread deals with the problem that there isn't a built-in way to find out whether the player just came out of a dialog. The code examples you posted don't make ANY SENSE AT ALL in this regard.
Title: Re: Continue after dialog
Post by: monkey0506 on Wed 05/10/2011 04:02:52
As promised, here's DialogPlus v0.1 (https://sites.google.com/site/monkey0506/DialogPlus_0.1.rar?attredirects=0&d=1). There's actually quite a bit more I'd like to do with this module, but for now it should give the requested functionality. Partial credit of course goes to Khris for pointing out that the repeatedly_execute function is always blocked by dialogs.

From the extremely simple documentation I did (in DialogPlus.ash):

// somescript.asc, inside some function
// do some stuff
dMerchant.Start();
// oh no, we need to do something after the dialog, oh noooo....

// later, in rep_ex
if (dMerchant.IsScriptFinished()) Display("YAY! The DialogPlus module has saved the day!");


The Dialog.IsScriptFinished function also takes one parameter, that I now realize I didn't mention in the documentation at all, that controls whether the dialog's script status should be cleared. The default value is true, so if you call this function with no parameters, then the function won't return true for the same dialog again until it has been run again. However, if you need to check the same dialog for "after" events multiple times, you can pass false to the function and it won't clear the script state.
Title: Re: Continue after dialog
Post by: SilverSpook on Wed 24/06/2015 09:40:01
I've been trying to use dialogplus, but whenever I do "IsDialogFinished()", it always returns false?  I tried passing "true" and "false" as an argument but the dialogs are never finished.  I put this function in room_repexec and tried repeatedly execute always also.