Continue after dialog

Started by TheRoger, Sun 02/10/2011 08:48:02

Previous topic - Next topic

TheRoger

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:

Code: ags

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?

steptoe

Have you used a Name for dDialog1.. I assume you may get an error message if dDialog1 does not exist.

It's not over until the fat lady sings..

TheRoger

It exists, I just didn't named it.

Code: ags

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


Three options, but gives same answer and continues cutscene.

David Ostman

#3
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.

Code: ags
@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 :)

Khris

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()"

TheRoger

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.

David Ostman

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

Khris

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.

Code: ags
  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);

pcj

You can also CallRoomScript() at the end of a dialog script for a more straightforward way.
Space Quest: Vohaul Strikes Back is now available to download!

monkey0506

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.

Khris

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.

Arjunaz78

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.

Code: ags
  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...

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


OR

Code: ags
 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)?
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Khris

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:

Code: ags
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:

Code: ags
  if (do_rad) {
    do_rad = false;
    on_after_dialog(rad);
  }


Add this line to the global header:

Code: ags
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.

Code: ags
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():

Code: ags
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.

monkey0506

As promised, here's DialogPlus v0.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):

Code: ags
// 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.

SilverSpook

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.

SMF spam blocked by CleanTalk