Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Akatosh on Fri 29/12/2006 15:52:17

Title: Parser Problem (SOLVED)
Post by: Akatosh on Fri 29/12/2006 15:52:17
The problem is: I want a certain response if the player types anything, and I mean anything, if the line includes a certain word, no matter what stands left or right of that word ("tool" in this case). I've tried the following code already:

If (Parser.Said("tool rol"))
Only works if nothing stands before 'tool'.

If (Parser.Said("rol tool rol"))
Always gives the response, even if there's no 'tool' in the line.

If ((Parser.Said("tool rol"))||(Parser.Said("rol tool")))
See above.

If (Parser.Said("[anyword] [anyword] [anyword] tool rol"))
Never gives the response, as weird as it sounds.

Any idea how to get this working? This is quite urgent, as this is a vital and basic feature of my game... and this isn't covered by the manual and the ags wiki entry is just a copy of that manual section. The technical archive is no help, too.

/EDIT: Corrected about 1,000 typos  :P
Title: Re: Parser Problem
Post by: Khris on Fri 29/12/2006 16:25:03
Before calling ParseText, check if the string contains "tool" (or " tool" or "tool ").
http://www.adventuregamestudio.co.uk/manual/String.Contains.htm

There's no way to do that with Said.

Btw, rol stands for "rest of line", so putting it at the beginning will match any text.
And my guess is, anyword will match any word, but [anyword] will only match an optional "anyword".
Title: Re: Parser Problem
Post by: Akatosh on Fri 29/12/2006 17:03:54
Thank you, I'll try that  :)

And I knew that with [anyword]; that's why I tried it - I thought this would work with 0, 1 or 2 words standing before 'tool', but that unfortunately wasn't the case.

/EDIT: Jup, it worked.
Title: Re: Parser Problem
Post by: Khris on Fri 29/12/2006 17:36:06
Quote from: Akatosh on Fri 29/12/2006 17:03:54/EDIT: Jup, it worked.

Big surprise... ;) :=

Of course I knew why you tried [anyword] [anyword] [anyword], what I meant was:

  Parser.Said("anyword tool") will match "eek tool", "oop tool", "poobungies tool", aso

but:

  Parser.Said("[anyword] tool") only matches "anyword tool" and "tool", not e.g. "eek tool"

since [anyword] is only treated as an optional word now, not as a placeholder any longer.

If this guess of mine is correct, then that was the reason why 3x [anyword] didn't match anything you tried.
Title: Re: Parser Problem (SOLVED)
Post by: Akatosh on Fri 29/12/2006 18:42:02
Yeah, I guess so. I think I'll post a suggestion in the tech forums that there'll be a 'anything' category added to the text parser, for which it doesn't matter whether it carries 'cowabunga', 'eek' or nothing.