Ask about dialogues

Started by ferrojcp, Yesterday at 05:52:43

Previous topic - Next topic

ferrojcp

Hello, I'm new, excuse my ignorance and because of my English I'm from Argentina, I'm starting with AGS and I'm doing this:

function cDominguez_Look(Character *theCharacter, CursorMode mode)
{
         
          player.Say("No se donde estoy, quizas este pueda ayudarme");
          cRoger.Walk(195, 170, eBlock, eWalkableAreas);
          cDominguez.Say("Hola de que fiesta de disfrazes venis?");
         

but I want it to end and not be said again how can I do it?
 I had put Dialog.Stop but it doesn't work when I click it says the same thing again

Snarky

#1
If you want something to be done only once, not every time a function is called, you can use Game.DoOnceOnly(). So if you want all of this to only happen the first time, you could write:

Code: ags
function cDominguez_Look(Character *theCharacter, CursorMode mode)
{
  if(Game.DoOnceOnly("First Dominguez look"))
  {
    player.Say("No se donde estoy, quizas este pueda ayudarme");
    cRoger.Walk(195, 170, eBlock, eWalkableAreas);
    cDominguez.Say("Hola de que fiesta de disfrazes venis?");
  }
  else
  {
    // Do something else
  }
}

As the manual explains, the string you put in DoOnceOnly (here I've used "First Dominguez look") can be whatever you want; the only important thing is that you don't accidentally use exactly the same string in another DoOnceOnly call.

By the way, you have player.Say and cRogerWalk. If cRoger is the player character, it would be better to try to be consistent.

Khris

For reference, Dialog.Stop() is explicitly about dialogs. These are conversations created in the dialog editor part of AGS, and those usually completely pause the rest of the game. Dialog.Stop() allows you to exit the current dialog from inside a regular script function and is rarely needed. The only sensible place to call it is repeatedly_execute_always because that is pretty much the only script function that actually runs during dialogs.

What you have there is a simple interaction function that happens to call .Say() commands but it's not a dialog in a technical sense.

In general, to provide different reactions in some event handler, you need to use the if or switch keyword to branch into different blocks of code, usually based on variables.

Here's an example using a room script variable:

Code: ags
int dominguez_reaction_count; // this integer variable is 0 when the game starts

function cDominguez_Look(Character *theCharacter, CursorMode mode)
{

  dominguez_reaction_count++; // increase by one

  if (dominguez_reaction_count == 1) // first time
  {
    player.Say("No se donde estoy, quizas este pueda ayudarme");
  }

  if (dominguez_reaction_count < 4) // first three times
  {
    player.Walk(195, 170, eBlock, eWalkableAreas); // approach the character
    player.FaceCharacter(cDominguez, eBlock);
  }
  
  switch(dominguez_reaction_count)
  {
  case 1:
    cDominguez.Say("Hola de que fiesta de disfrazes venis?");
    break;
  case 2:
    player.Say("Sorry to bother you again.");
    // ...
    break;
  case 3:
    player.Say("I still had a question.");
    // ...
    break;
  default:
    player.Say("I don't want to talk them anymore.");
  }
}

Crimson Wizard

Quote from: Khris on Yesterday at 10:12:41Dialog.Stop() allows you to exit the current dialog from inside a regular script function and is rarely needed. The only sensible place to call it is repeatedly_execute_always because that is pretty much the only script function that actually runs during dialogs.

Small addition: Dialog.Stop() may be called from any script function if it's run from the dialog script.

BTW historically it could be called only from "dialog_request", which is run when you do "call-script" command from the dialog script, but recently I've fixed it to work regardless of how where it's called from, so long as there's a dialog running. Also, in some circumstances it is not an instant stop, but scheduled until execution returns to the dialog script.

SMF spam blocked by CleanTalk