[SOLVED] Global variable and Dialog

Started by ShinjinNakamura, Wed 03/07/2013 18:56:26

Previous topic - Next topic

ShinjinNakamura

Salam,
I intended to use a global variable to make multiple dialogs on a single character.
I defined the variable in the interface (BoramTalk, with starting value 1), and wrote this code:
----------------------------------------------------------------------------
Code: AGS

function cBoram_Talk()
{
cHyomin.FaceCharacter(cBoram);
cHyomin.LockView (VIEW3);
cHyomin.Animate(0, 1, eOnce, eNoBlock, eForwards);
SetSkipSpeech(3);
cHyomin.Say ("Boram! What are you doing?!");
cBoram.Say("Eating cake!");
cHyomin.Say("How did you get IN the cake though?!");
cBoram.Say("A story better left untold.");
cHyomin.Say("If you say so...");
cHyomin.UnlockView();
cHyomin.Say("Enjoy your cake then I guess!");
cBoram.Say("Wait! Help me eat it all so I can get out!");
cBoram.Say("The boss will kill me if he finds out I went against my diet!");
cHyomin.Say("I can't eat all that!");
cBoram.Say("Well get the others here and help me then!");
cHyomin.Say("Ok...");
BoramTalk += 1;
}

if (BoramTalk == 2)
{
{cBoram_Talk() = false}
{
function  cBoram_Talk2()
{cBoram.Say ("Nom Nom");
}
}
}

-----------------------------------------------------------------
When the character Boram is clicked on once, the function cBoram_Talk runs.
With it I added the line BoramTalk += 1;
With this the variable value should go up to 2.
And going on to the if statement: it makes cBoram_Talk false and initiates cBoram_Talk2

The problem for me is this[ GlobalScript.asc(78): Error (line 78): Parse error: unexpected 'if']

Also I tried putting this dialog in the room script (because the character stays in the same room), but it doesn't initiate then.


Khris

That's not how it works.
You can't just turn off a function.

Do this:

Code: ags
function cBoramTalk() {

  if (BoramTalk == 1) {
    // stuff happens
    BoramTalk += 1;
  }
  else if (BoramTalk == 2) {
    cBoram.Say ("Nom Nom");
  }
}


Note that even if what you tried did work, the two different events would still both have fired in sequence after the first click, since you're incrementing BoramTalk, then checking for it being 2.
Either use an "else if", like I did, or put the "if (BoramTalk == 2)" block above the other one, or exit the function at the end of the first block with "return;".

ShinjinNakamura


SMF spam blocked by CleanTalk