trigger when dialog has ended.

Started by Seventeen Uncles, Fri 19/09/2014 21:37:19

Previous topic - Next topic

Seventeen Uncles

Hi all another noob question from me. How do I trigger an event after a dialog has ended. ie after a dialog the NPC disapears. I've worked out by looking at the manual/wiki to use transparency and/or move to get rid of the NPC, but how can i trigger it to occur once the dialog has ended?

if i try and put it in the NPC talk function in the GlobalScript, regardless of if i put it after the dialog start code, it happens immediately upon speaking to the NPC rather than when the dialog has ended.

once again any help is greatly appreciated.

Cassiebsg

#1
Hey.

Try putting your code on the exit option of your dialog. ;)

Like this:
Code: ags

@4
	your code here
stop


EDIT: Oops, sorry read your question a bit to fast.

You can either do a
Code: ags

if ((dMRandy001.GetOptionState(2) == eOptionOff)


Or do a check for if the dialog has runned.

Code: ags

dialog.HasOptionBeenChosen


Hope it helps. :)

There are those who believe that life here began out there...


Khris

Just for reference, you can also set a global variable and check it in rep_exe:

Code: ags
// in dialog 5's script, before "stop"
  dialog_ended = 5;

// top of Global Script, or custom script
void DialogEnded(int id) {
  if (id == 5) {
    // this runs after dialog 5 has ended
    ...
  }
}

  // in repeatedly_execute
  if (dialog_ended) {
    DialogEnded(dialog_ended);
    dialog_ended = 0;  // reset
  }

monkey0506

If you want to do this generically (e.g., do something when any dialog ends, like turn a GUI back on), you can combine Khris' suggestion with the custom dialog rendering options. Basically you can tell that a dialog has started by setting a variable in dialog_options_get_dimensions or dialog_options_render and then tell that a dialog has ended when repeatedly_execute is triggered.

Seems like you got it sorted out, but just wanted to mention an alternative that lets you know when any dialog has ended without having to modify every dialog script.

SMF spam blocked by CleanTalk