Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SiraRaven on Mon 13/07/2009 07:22:27

Title: Scripting commands in a dialogue (SOLVED)
Post by: SiraRaven on Mon 13/07/2009 07:22:27
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!
Title: Re: Scripting commands in a dialogue
Post by: Galen on Mon 13/07/2009 12:03:08
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.
Title: Re: Scripting commands in a dialogue
Post by: Vukul on Mon 13/07/2009 13:06:26
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.
Title: Re: Scripting commands in a dialogue
Post by: Ishmael on Mon 13/07/2009 15:40:25
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.
Title: Re: Scripting commands in a dialogue
Post by: SiraRaven on Mon 13/07/2009 16:13:04
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!
Title: Re: Scripting commands in a dialogue
Post by: Ishmael on Mon 13/07/2009 17:12:10
Ah, ofcource. That's what you get when reading this stuff half-asleep. Yeah.
Title: Re: Scripting commands in a dialogue
Post by: Khris on Mon 13/07/2009 17:12:36
Yes, to clarify, GUYATSCHOOL gets replaced with the character's ID (1), thus the parse error at "1.".