Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GoodGuy on Sat 25/03/2017 07:56:31

Title: Operator If in dialog script
Post by: GoodGuy on Sat 25/03/2017 07:56:31
Hi. I have a example code of dialog
Code (ags) Select
@1
Smb: I wanna drink.
  if (Ã'Ego.HasInventory(iJuice))
    Ã'Ego.LoseInventory(iJuice);
stop

I want to branch out a dialog
Code (ags) Select
@1
Smb: I wanna drink.
  if (Ã'Hero.HasInventory(iVodka)) {
    Ã'Hero.LoseInventory(iVodka);
    //goto-dialog X or dialog_request
    }
    else
    {
    //goto-dialog X or dialog_request
    }
stop

How can I can do it?

Another question: What are RUN_DIALOG_GOTO_PREVIOUS, RUN_DIALOG_RETURN and RUN_DIALOG_STOP_DIALOG doing?
Title: Re: Operator If in dialog script
Post by: Cassiebsg on Sat 25/03/2017 08:28:52
Quote from: GoodGuy on Sat 25/03/2017 07:56:31
I want to branch out a dialog
Code (ags) Select
@1
Smb: I wanna drink.
  if (Ã'Hero.HasInventory(iVodka)) {
    Ã'Hero.LoseInventory(iVodka);
goto-dialog X // You can just remove the indentation, since goto-dialog is a dialogue command, not a script command.
    }
    else
    {
    //goto-dialog X or dialog_request
    }
stop



Title: Re: Operator If in dialog script
Post by: Khris on Wed 29/03/2017 09:27:35
Another way is to simply start the other dialog:
  if (Ã'Hero.HasInventory(iVodka)) {
    Ã'Hero.LoseInventory(iVodka);
    dVodka.Start();
    return RUN_DIALOG_STOP_DIALOG;
  }

Untested! But I guess this should do the trick.

Quote from: GoodGuy on Sat 25/03/2017 07:56:31Another question: What are RUN_DIALOG_GOTO_PREVIOUS, RUN_DIALOG_RETURN and RUN_DIALOG_STOP_DIALOG doing?

Instead of using a non-indented dialog command like goto-previous you'd call "return RUN_DIALOG_GOTO_PREVIOUS;" in an indented script block.