Command Execution

Submitted by javelin on Sat, 2002-11-30 18:21

When a player types a command, or when a command is dequeued from the queue to be run, it is passed to the command parser, process_command(). In the command parser, the first word of the input is mangled a bit -- spaces are squished, a outer layer of curly braces may be stripped, and %-substitutions are evaluated (the expression parser is used to do these things - it's not just for functions!) To see this behavior at work, type: {say } foo

The command parser now attempts to match the input in the following order, and stops as soon as one of these works:

  1. The complete input to a local exit
  2. The first word (or token in the case of several special symbols like double-quote, colon, etc.) of the input to a standard mushcode command. If this doesn't match, the command parser evaluates the rest of the input (as above, squishing spaces, stripping braces, and evaluating %-substitutions but not functions) and continues.
  3. The complete input to an enter alias of an object in the room
  4. The complete input to a leave alias of the current container
  5. The complete input to $commands on objects in the player's location (including the player)
  6. The complete input to $commands on the current container
  7. The complete input to $commands on objects in the player's inventory
  8. The complete input to exits in the zone master room, if any
  9. The complete input to $commands on objects in the zone master room, if any
  10. The complete input to $commands on the zone master (non-room) object, if any
  11. The complete input to $commands on the player's personal zone, if any
  12. The complete input to exits in the master room, if any
  13. The complete input to $commands on objects in the master room, if any

Then, usually, the commands' arguments are passed to the function parser to be evaluated. The command itself is then run with the evaluated arguments. There are two exceptions to this behavior: commands that get the /noeval switch receive their arguments without this evaluation step, and the &attrib <obj>=<value> style of attribute setting does not evaluate the <value> when run directly by a player descriptor.