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!
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.
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.
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.
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!
Ah, ofcource. That's what you get when reading this stuff half-asleep. Yeah.
Yes, to clarify, GUYATSCHOOL gets replaced with the character's ID (1), thus the parse error at "1.".