Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Sat 26/04/2003 12:45:42

Title: Need help with optional words in parser
Post by: on Sat 26/04/2003 12:45:42
G'day.

As the help happily says, you can put a word you want to be optional into a pair of square bracket.  And this is good because nobody wants to add lots of ORs.

Since I am stupid and I want to make one of those "let-the-fool-user-believe-he-is-chatting-with-a-real-person" programs, like ECC-ELIZA or something like that, I thought that putting "ANYWORD" in square brackets would have been very useful. In fact, in these "pseudo-AI" programs it would be better to recognize a word into a sentence, no matter the position.

Thus, I put [anyword] into square brackets, but damnit, it doesn't work.

I put something like this

if (Said("[anyword] AGS")) DisplaySpeech(EGO,"It's a nice tool.");

if in the game I simply write AGS,  it comes out saying nothing, because the word AGS is in the dictionary, and it is recognized, but it doesn't have anyword before, and so EGO doesn't say anything.

Is there a way to work around this? I can solve the problem by ORing sentences, but is there some thing I have overlooked? Is this a bug or it was meant? I'm waiting.

Saludos.

CUG
Title: Re:Need help with optional words in parser
Post by: RickJ on Sun 27/04/2003 00:02:19
Have you tried something like this ...

  if (Said("anyword AGS")) DisplaySpeech(EGO,"It's a nice tool.");

I haven't done much with the parser but you probably can't use special keywords inside brackets the way you expect.  
Title: Re:Need help with optional words in parser
Post by: Pumaman on Sun 27/04/2003 16:17:26
Actually, it does work - but it's not doing what you expect.

It goes through the sentence from left to right, matching up words. So, it sees:

[anyword]

and compares it to the user input

AGS

and yes! AGS is any word, so that matched up! Now, it carries on, and tries to match

AGS

from your Said query, with nothing, because it has exhausted the user input. This, obviously, fails.

Basically, putting anyword in square brackets will have no affect, because any word will always match it.

You'll have to do this specific instance with ORing two Said's:

if ((Said("anyword AGS")) || (Said("AGS")))
Title: Re:Need help with optional words in parser
Post by: on Sun 27/04/2003 20:14:36
Aha, stupid me. Thanks A-Lot, my "Fake chat" game can stride forth.

Saludos.

CUG