Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FauxSang on Sat 07/06/2014 01:39:23

Title: Test if dialog has been used
Post by: FauxSang on Sat 07/06/2014 01:39:23
What is the proper way to test if a dialog has been "used" before?  Pseudo code:

(note: I'm using the MI-style 9 verb template, so everything is in AnyClick)

Code (ags) Select

function cBartender_AnyClick()
{
  // TALK TO
  if (UsedAction(eGA_TalkTo)) {
    if (player and bartender have never had conversation dDialog1) {
      dDialog1.Start();
    } else {
      dDialog2.Start();
    }
  }
  // end TALK TO
}
Title: Re: Test if dialog has been used
Post by: FauxSang on Sat 07/06/2014 02:55:36
FWIW, I'm doing this by declaring a global variable called bartenderDialog1Used = false.  After calling dDialog1.Start(), I set it to true.  Feels kinda dirty, though.
Title: Re: Test if dialog has been used
Post by: Gurok on Sat 07/06/2014 03:10:27
Sounds fine to me! I would have suggested exactly that.

If this is the only place dDialog1 is used, you could use Game.DoOnceOnly. You just need to pass it a unique token, e.g.:


if(Game.DoOnceOnly("player and bartender have never had conversation"))
    dDialog1.Start();
else
    dDialog2.Start();


It's cumbersome, but you could also loop through from 0 to dDialog1.OptionCount and see whether dDialog1.HasOptionBeenChosen is true for any of the options.

That's about all I can think of for now. HTH
Title: Re: Test if dialog has been used
Post by: FauxSang on Wed 11/06/2014 05:24:36
Ah, nice.  I like the HasOptionBeenChosen check, that seems cleaner to me.  I dislike using globals when I can avoid it.  Thanks!
Title: Re: Test if dialog has been used
Post by: Gabarts on Sat 14/06/2014 00:25:02
I've tried using this condition on_Room Load to Restore a Walkablearea after a certain dialog option with no success...

Here the code:

Code (ags) Select
function room_Load() {
SetTimer(1, 600);
SetTimer(2, 2400);
 
  if (dDialog5.HasOptionBeenChosen(4)) {
   RestoreWalkableArea(2);
}
  else {
   RemoveWalkableArea(2);
}
}


Plus I have a little question about the music transition between rooms, but I will use another thread in case...
I coded:
Code (ags) Select
function room_AfterFadeIn()
{
aIndy_Venezia.Play();
}

When I change the next room music can be heard and is fine. But once I return back to the Room where there is that code, the music suddenly interrupts and start again.
Title: Re: Test if dialog has been used
Post by: Khris on Sat 14/06/2014 09:59:41
The original issue seems to be resolved, so I guess we can go OT a bit.
The first code snippet seems fine, but the first step to debug this is to add Display()s next to the commands to make sure they're actually called. I don't remember if Display() works in room_Load (since the room hasn't been faded in yet) but I dimly remember that this used to not, then was changed to work. just try it.

As for the second snippet, a .Play() command doesn't care whether the music is already playing, it'll simply start over in that case. Asked and answered multiple times already though: http://www.adventuregamestudio.co.uk/forums/index.php?topic=50363.msg
Title: Re: Test if dialog has been used
Post by: Gabarts on Sat 14/06/2014 10:15:13
In fact it was right Khris :)

My fault in the room editing, I missed a whole line to join the 2 areas...
Title: Re: Test if dialog has been used
Post by: Gabarts on Sun 15/06/2014 10:03:47
I tought was an editing problem in the room, instead it's still not working.
The code is fine but it takes effect only loading the room.

The situation is this:

I have the dialog, the option is checked, the passage is free but the player is already in the room and the Walkable area is not restored. I need to exit and re-enter again in the room.
Title: Re: Test if dialog has been used
Post by: Khris on Sun 15/06/2014 10:24:38
In the dialog script, in option 4's commands, add:
Code (ags) Select
RestoreWalkableArea(2);  // indent by at least one space