Operator If in dialog script

Started by GoodGuy, Sat 25/03/2017 07:56:31

Previous topic - Next topic

GoodGuy

Hi. I have a example code of dialog
Code: ags
@1
Smb: I wanna drink.
  if (Ã'Ego.HasInventory(iJuice))
    Ã'Ego.LoseInventory(iJuice);
stop

I want to branch out a dialog
Code: ags
@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?

Cassiebsg

Quote from: GoodGuy on Sat 25/03/2017 07:56:31
I want to branch out a dialog
Code: ags
@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



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

Khris

#2
Another way is to simply start the other dialog:
Code: ags
  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.

SMF spam blocked by CleanTalk