Making A Dialogue Option Show Once All Others Have Been Used

Started by ROBRO, Thu 26/11/2020 10:16:25

Previous topic - Next topic

ROBRO

Code: ags

  if(dDyingManDialogue.HasOptionBeenChosen(1) && dDyingManDialogue.HasOptionBeenChosen(2) && dDyingManDialogue.HasOptionBeenChosen(3))
  {
  dDyingManDialogue.SetOptionState(4,eOptionOn); 
option-on 4
  }


The above code works. However, I have to place it under each dialogue option like so...

Code: ags

@1
DyingMan: blah blah blah.
  if(dDyingManDialogue.HasOptionBeenChosen(1) && dDyingManDialogue.HasOptionBeenChosen(2) && dDyingManDialogue.HasOptionBeenChosen(3))
  {
  dDyingManDialogue.SetOptionState(4,eOptionOn); 
option-on 4
  }
return


...in order for AGS to actually check it. This seems like a messy way to do it so I am wondering is there a better way? I did find an old thread where one user suggested placing it under @S, as he claimed that AGS checks this each time an option is clicked, however that does not work.

Khris

Afaik, the @S entry point is only used at the start of a dialog; can you link us to the thread that claims otherwise?

A similar situation came up recently here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=58592.0
The question was about auto-exiting the dialog but the solution also applies here: instead of copy pasting the entire if block, move it to a function and call the function instead.

eri0o

Hey @Snufkin, can you explain what you are trying to accomplish? Also AGS Script on dialog editor has to be on a line that starts with at least one space, otherwise it will be interpreted wrong.

You can try to put

Code: ags
function checkAndEnableFinalOpt()
{
  if(dDyingManDialogue.HasOptionBeenChosen(1) && dDyingManDialogue.HasOptionBeenChosen(2) && dDyingManDialogue.HasOptionBeenChosen(3))
  {
    dDyingManDialogue.SetOptionState(4,eOptionOn); 
  }
}


In a script module, import it, and call this function at the end of dialog options 1, 2, and 3 calls.

ROBRO

Hi.

@Khris
Thread is this one here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54542.0
Third post down by Kumpel who writes the following.

QuoteYou could shorten the whole thing if you add a hidden 4th option which is activated in the "@S area" (checked every time you do return) and starts autmatically if all three other options are off. And in this option you add the dialog change. But your version works too, thus it's all right ;)

Unless I misread it, he means that @S gets checked after you click an option? This is not what I found however.

@eri0o
@Khris
A function would simplify so I will do that, although having to place a function call in each dialogue choice still seems messy to me. Is it the best that can be done? What about a way to sort of streamline the function so it can be used for any dialogue, or do I need to make a function that does something similar if I end up wanting it again for a different dialogue?

Crimson Wizard

Quote from: Snufkin on Thu 26/11/2020 13:02:04
Thread is this one here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54542.0
Third post down by Kumpel who writes the following.

QuoteYou could shorten the whole thing if you add a hidden 4th option which is activated in the "@S area" (checked every time you do return) and starts autmatically if all three other options are off. And in this option you add the dialog change. But your version works too, thus it's all right ;)

Unless I misread it, he means that @S gets checked after you click an option? This is not what I found however.

Hmm, I don't think this is exactly what Kumpel said, I think he meant, add an option that is disabled by default, but enabled in @S with option-on. So it won't be available for a player to select, but will run automatically when there are no other options. Or something along these lines.

Khris

Sounds like Kumpel was either mistaken or thought that OP was referring to starting a Dialog multiple times.
OP's issue sounds exactly like the recent one I linked to though.

guga2112

Yep, I'm the one who had the "exit dialog once all options have been chosen" and it seems basically the same.

In my solution I'm checking whether the options are all off, and if so, it activates a new one (which just exits the dialog).

@Khris had the very same solution and the code is very clean. Just check if all options have been chosen (at least those that are on, if you don't disable them after choosing) and if so, activate the new one

SMF spam blocked by CleanTalk