How do I get around "I don\'t know which you mean"?

Submitted by javelin on Sun, 2012-02-12 22:52

How do I get around "I don\'t know which you mean"?

In versions of PennMUSH before 1.7.4p2 or so, when you have multiple objects with the same name, and you try to match one (by using \'get thing\', \'look thing\' or any other command), the command will work, but on an arbitrarily chosen one of the objects (sometimes randomly chosen, sometimes the first one in the room\'s contents).
As of 1.7.2p2, the parser correctly interprets this situation as one of ambiguity, and instead of choosing for you, reports "I don\'t know which you mean" or similar, functions return #-2, etc.
But what do you do if you need to write code that acts on one of the objects? How can you choose a particular one?
The solution is English matching. Since 1.7.3, PennMUSH has supported the following adjectives before object names:

  1st/2nd/3rd/4th/etc.  -- to specify the xth object visible to you
  my 1st/2nd/3rd/etc.   -- the xth object in your inventory
  this here 1st/2nd/etc. - the xth object in the room with you

(\'this here\' may be abbreviated \'here\')
So if you write a vendor that creates identical objects and gives them away, rather than have it \'give %#=object\', use \'give %#=my 1st object\' and you can be sure it will work, even if your vendor somehow comes to contain multiple \'object\' objects.
Of course, if you know dbrefs, you can always work by dbrefs as well.
(And if you have side-effect functions, write your vendors to use create(),
and keep the dbref, and operate that way!) You can often get dbrefs using the locate() function, which can be instructed to treat ambiguous cases in the old style (returning an arbitrary matching object), as well as to use english matching.

2001-May-19 12:33pm dunemush

In recent versions, there is also "toward" for exits. For example, if there\'s two exits going east, "toward 1st east" will reference the first east exit.

2003-Apr-23 7:22am pmak