Bug: Parser problems with spaces & optional words (FIXED)

Started by Rui 'Trovatore' Pires, Thu 02/02/2006 20:01:50

Previous topic - Next topic

Rui 'Trovatore' Pires

The "comma" and two-parser words don't seem to get along well.

if (Said("examine roger")) Display("It's Roger.");
if (Said("look at roger")) Display("It's Roger.");

Both of the above work well.

if (Said("examine, look at roger")) Display("It's Roger.");

The above doesn't. When I try to "look at roger", it quits saying " "at" is not a word in the dictionary, or is an ignore word". Quite true, it's not there. But "look at" is, and that's what it should check for - and indeed, what it sucessfully checks for in the first examples.

I work around it very easily by using "examine,look" and having "look" and "look at" defined as synonims, but it's still worth looking into, isn't it?

On a sidenote: Parser.Said() has replaced Said(), but Said() is still available. I'd just like to ask that it remain available. When working with the parser, Said() is about as common as Display(), and Parser.Said() is much too cumbersome to write, especially since it's actually two words for autocomplete.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

DoorKnobHandle

#1
I don't know a lot about the parser itself, but I'd like to comment on the function "Said ( )". Since my real programming experience is based on solely C++, I think the global function "Said ( )" should be removed and that only "Parser.Said ( )" is left. It helps organize stuff better and goes along with the new "OO" design of the editor. With "Said" it's not clear what is meant. Did a character say something? "Parser.Said" makes it clear.

And if you really don't want to write those 11 characters over and over, then define yourself a simplifying function like this:

Code: ags

function s ( bla )
{
   Parser.Said ( bla );
   // whatever
}

Rui 'Trovatore' Pires

#2
And so ease of use suffers because of the new categorization? The way you put it, it may sound measly, but ask anyone who's used the text parser (I myself have written two templates using it, and a couple of projects have been started). When you have to type a lot of it, you don't want to type all that much. Like with Display, you want to type the first couple of characters and press Enter for auto-complete to do its stuff. Yes, a function is a workable workaround, but doesn't it strike you as a bit of a hack? AGS is meant to be easy to use (and it is), and CJ has taken great pains along that path over the years. This is just, IMHO, as a parser user, a detail that makes it less cumbersome and more "enjoyable" - regardless of organization.

Anyway, just making my point here, 's all I'm doing. I'd rather that either Said() remained available, as it is, or that the Parser functions got de-objectized. Which is overkill if both commands can, as they do, co-exist peacefully.

EDIT - I'd be interested to know of other possible interpretations for "Said". Is there likely to be a function that accepts a potentially huge string to be called when a character has just "said" something?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pumaman

#3
Interesting bug, well spotted!

Try this as a workaround for now:

if (Said("look at,examine roger")) Display("It's Roger.");

If the word with the space comes first, it works ok -- I'll look into a proper fix.

Edit by strazer:

AGS v2.72 Beta 3:
* Fixed text parser not handling a choice of words with spaces properly in Said().

Rui 'Trovatore' Pires

#4
This just in (double-posting because it's not really related to the above post):

The following line:

if (Said("[go,move] north")) {

...errored out on me, saying word " (yes, word ") was not in the dictionary, or was an ignore word. Well, the word that caused this was "go", and it was in the dictionary, and wasn't an ignore word. So I changed it to:

if (Said("[move,go] north")) {

And now the word "go" worked well, and "move" errored out. And doing

if (Said("go,move north")) {

presented me with no problems, although it's not the behaviour I wanted.

To sum it up: there's apparently a problem with using the [ operator in the parser in the first word (or, if using commas, set of words).

EDIT - Whee! CJ saved me from doing a double posting by his timely response!

EDIT 2 - I just wanted to point out this second bug... y'see, CJ, I posted so soon after your last post I think you may not have seen it.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pumaman

#5
You're right, I missed that, will look into it.

Edit by strazer:

AGS v2.72 Beta 3:
* Fixed text parser not handling an optional choice of words properly.

SMF spam blocked by CleanTalk