Scripting commands in a dialogue (SOLVED)

Started by SiraRaven, Mon 13/07/2009 07:22:27

Previous topic - Next topic

SiraRaven

I've read through the section in the manual on using scripting commands in a dialogue, and I can't find what I'm doing wrong.  Here's what I have written:

// Dialog script file
@S  // Dialog startup entry point
return
@1
 if (player.HasInventory(iKey))
   GUYATSCHOOL.Say("You will understand...in time");
 else{
   GUYATSCHOOL.Say("To give you this.");
   player.AddInventory(iKey);
   Display("You received a key");
   GUYATSCHOOL.Say("You will learn its use...in time.");
  }
return
@2
GuyAtSchool: If you say so...
goto-previous

Whenever I try to run it, I get "Error (line 5): PE04: parse error at '1.'  Any help would be greatly appreciated.  While I have a fair bit of programming experience, I'm new to AGS - I'm really enjoying it so far!

Galen

#1
Try if (player.HasInventory(iKey) == true) {
guy at blah blah

} else ...


If not then check you've used the right case for guyatschool, make sure it isn't cGuyAtSchool or something.

Vukul

Hm, I tried to implement your code... And it works without any glitches and whatsoever.

Some points to ponder on:
- does that parser error really occur while the engine is checking the dialogue syntax?
- do both dialogue options exist in the dialogue itself (i.e. they have their text etc.)?
- try to create some other dialogue option and copy/paste the code there,
and for the @1 put some usual dialogue messages... And see if the error still exists.
  

Ishmael

#3
I've noticed not using braces in a multi-line condition gives errors. In case that would've been the problem, the fix at it's simplest form would be (in addition to the wrong captalization of the character script name):

if (player.HasInventory(iKey)) cGuyAtSchool.Say("You will understand...in time");

But if that doesn't work for a reason or another, then it's

if (player.HasInventory(iKey)) {
  cGuyAtSchool.Say("You will understand...in time");
} else {

as said before.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SiraRaven

Thanks everyone for your help!  The problem ended up being that I was sending 'GUYATSCHOOL' the 'Say' command rather than 'cGuyAtSchool', as Crazy suggested.  Thanks for all the suggestions!

Ishmael

Ah, ofcource. That's what you get when reading this stuff half-asleep. Yeah.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Khris

Yes, to clarify, GUYATSCHOOL gets replaced with the character's ID (1), thus the parse error at "1.".

SMF spam blocked by CleanTalk