Test if dialog has been used

Started by FauxSang, Sat 07/06/2014 01:39:23

Previous topic - Next topic

FauxSang

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

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
}

FauxSang

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.

Gurok

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.:

Code: ags

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
[img]http://7d4iqnx.gif;rWRLUuw.gi

FauxSang

Ah, nice.  I like the HasOptionBeenChosen check, that seems cleaner to me.  I dislike using globals when I can avoid it.  Thanks!

Gabarts

#4
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
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
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.

Khris

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

Gabarts

In fact it was right Khris :)

My fault in the room editing, I missed a whole line to join the 2 areas...

Gabarts

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.

Khris

In the dialog script, in option 4's commands, add:
Code: ags
 RestoreWalkableArea(2);  // indent by at least one space

SMF spam blocked by CleanTalk