[SOLVED] Can we stop the parser from matching objects from the first few letters? (Revisited)

Hello.

I know this has been asked before, but I'll gosh darned if I can find the post(s).

If there is a cart in the room, I can enter GET CAR and the game understands "get cart".

Same thing with headphones (as I recall someone pointing out in the long ago, far far away post). I can enter GET HEAD and pick up the headphones.

Did we end up with some code to change that behavior?

I am currently porting an old game to Quest 5. I want the parser to match no less than six characters before declaring a match (unless, of course, the object has an alias/name which is less than six characters long, in which case I want the player to have to type the whole thing).

It seems like there's a DisambiguateNames() function or something? (If so, I can't find it.)


Found it, but I can't think clearly enough to modify the second else bit.


EDIT

Got it (as far as my port is concerned). I don't even need the second else bit.

The game I'm porting doesn't try to match to anything that doesn't include the first word, anyway.

I.e., if I have a flathead screwdriver, I have to add screwdriver as an alias if I want the parser to understand that.

...and if I had a beer your friend XanMag gave you which you can't seem to open, I would probably only add "xanmag's beer" as an alias. This way, EXAMINE YOUR wouldn't match that beer.

Let's call this the INFOCOM Mod of CompareNames():

BAD CODE REMOVED

Okay, I'm messing this up.

You could enter the first six characters in old text adventures because the system could only store names as strings up to six characters long.

The game I'm porting only matches against the first six letters of the name and alias(es).

Let's call this the INFOCOM Mod of CompareNames():

  <function name="CompareNames" parameters="name, value, obj, fullmatches, partialmatches"><![CDATA[
    if (name = value) {
      if (not ListContains(fullmatches, obj)) {
        list add (fullmatches, obj)
      }
    }
    else {
      // Modified to only check for 6 characters or more
      if (LengthOf(value) >= 6 and StartsWith(name, Left(value,6))) {
        if (not ListContains(partialmatches, obj)) {
          list add (partialmatches, obj)
        }
      }
    }
  ]]></function>

The mysterious adventures series (which I've made Quest conversions of 2 games) only matched the first 4 characters :) Looks like it's pretty similar.

Apparently I didn't check the forums last night; though you got pretty much the same code I would have managed off the top of my head.

Although, thinking about it, if I wanted to accurately emulate the behaviour of the games I'm familiar with, it would have been simpler to do just:

  if (Left(Replace (name, " ", ""), 4) = Left (Replace (value, " ", ""), 4)) {
    list add (fullmatches, obj)
  }

Log in to post a reply.

Support

Forums