Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gurok on Sat 01/03/2014 14:04:57

Title: ESC to exit a dialog (conversation)
Post by: Gurok on Sat 01/03/2014 14:04:57
Hello,

When conversing with another character, is there an easy way to allow the player to press ESC to exit the dialog? Ideally I'd like to be able to have the player say goodbye when ESC is pressed, but I'd settle for just stopping the dialog.
Title: Re: ESC to exit a dialog (conversation)
Post by: Crimson Wizard on Sat 01/03/2014 14:51:37
The only way I know to intercept a keypress when dialog options are display is to do this in repeatedly_execute_always:

Code (ags) Select

function repeatedly_execute_always() {
  if (IsKeyPressed(eKeyEscape))
  {
    // do something
  }
}


Now, the problem is that:
- StopDialog() only works when being called from a dialog_request handler (that is - after certain option was chosen and "run-script" command is used under that option).
- It will perhaps be better anyway if certain "ending" dialog part was played, otherwise this will act the same for every dialog.

The solution is either
1) script your own dialog options system (probably not very difficult), or
2) try making new "BreakDialog" and/or "RunDialogOption" script functions :).
Title: Re: ESC to exit a dialog (conversation)
Post by: Gurok on Sun 02/03/2014 06:59:47
I took a look at the code and I think it's easier to just live with limited dialog options for now.

Thanks for the answer though, CW. I appreciate the perspective.