How the MOO interprets commands

There is a very good section in the Programmer's Manual on this, but I'll try to explain it in my own words here.
The MOO server can handle three basic types of command:

command
eg 'smile', 'look', 'frown'

command direct-object
eg 'get book', 'drop suitcase', 'poke Mort'

command [direct-object] preposition indirect-object
eg 'get brush from box', 'look at Mort' (this has no direct object), 'unlock door with key'

Once the MOO has sorted out which of these categories the command falls into, it tries to find the direct and indirect objects in the game. For example the book, the suitcase, me, the brush and the box, etc. Once it has done this, it looks on several objects for a verb that matches the syntax.
In order it looks on:

  1. the player who issued the command
  2. the room the player is in (if any)
  3. the direct object (if any)
  4. the indirect object (if any)
Each verb has a set of 'argument specifiers'. This determines what syntax is valid for using the command. I'll start with an example.
The 'unlock' command is stored on the key object, as the only thing that unlocks things is a key. The specifiers are 'any' 'with' 'this' - refering to the direct object, the preposition and the indirect object respectively. 'Any' means that anything can go here, so long as it's not a preposition. The preposition must be 'with' - you don't unlock doors to the key, or unlock the car on the key... you unlock with keys. 'this' means that the command needs to include the name (or something that matches) this particular object. You're doing the unlocking with this particular key, rather than any other.
There's also another useful argument specifier - 'none'. For the 'get book' example, the specifiers would be 'this' 'none' none' - the particular object you want to drop, with no preposition and no indirect object.

What if the command you want to write doesn't look like any of the three templates?
The easiest way to get something to run without having an explicit direct or indirect object, or preposition, is to put the verb on the room or player, and give it the arguments 'any' 'any' 'any'. Then it can have any direct object, any prepostion (or none), and any indirect object (or none). After that you'll need to write code to interpret the command yourself as part of the verb.
If the verb is not a command, but is called by other verbs as a 'function', then the arguments should be 'this' 'none' 'this'. This will mean that it can never be used as a command - it's impossible to have an indirect object without a preposition!

So, the valid specifiers are:
Direct ObjectPrepostionIndirect Object
this(a particular preposition)this
anyanyany
nonenonenone

There's more to it than just that - but that's for experienced hackers - we'll go into it later on.


Last modified: Tue Sep 14 23:32:57 GMT 1999