Author Topic: Parser Problem (SOLVED)  (Read 217 times)  Share 

Akatosh

  • Still dropping by every couple of months
    • Best Innovation Award Winner 2007, for '_Access'
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
  • Akatosh worked on a game that was nominated for an AGS Award!
Parser Problem (SOLVED)
« on: 29 Dec 2006, 15:52 »
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:

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

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

[code]If ((Parser.Said("tool rol"))||(Parser.Said("rol tool")))[/code]
See above.

[code]If (Parser.Said("[anyword] [anyword] [anyword] tool rol"))[/code]
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
« Last Edit: 29 Dec 2006, 17:09 by Akatosh »

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Parser Problem
« Reply #1 on: 29 Dec 2006, 16:25 »
Before calling ParseText, check if the string contains "tool" (or " tool" or "tool ").
http://www.bigbluecup.com/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".
« Last Edit: 29 Dec 2006, 16:29 by KhrisMUC »
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Akatosh

  • Still dropping by every couple of months
    • Best Innovation Award Winner 2007, for '_Access'
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
  • Akatosh worked on a game that was nominated for an AGS Award!
Re: Parser Problem
« Reply #2 on: 29 Dec 2006, 17:03 »
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.
« Last Edit: 29 Dec 2006, 17:08 by Akatosh »

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Parser Problem
« Reply #3 on: 29 Dec 2006, 17:36 »
/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.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Akatosh

  • Still dropping by every couple of months
    • Best Innovation Award Winner 2007, for '_Access'
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
  • Akatosh worked on a game that was nominated for an AGS Award!
Re: Parser Problem (SOLVED)
« Reply #4 on: 29 Dec 2006, 18:42 »
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.