[Coldstuff] Command Overrides

Brandon Gillespie coldstuff@cold.org
Fri, 15 Feb 2002 13:45:52 -0700


On Wed, Feb 13, 2002 at 09:23:28PM -0500, jon@enter.net wrote:
> So I was thinking tonight about command overrides, and how they functioned
> in the last environment I worked in, and how to implemented them in my
> current environment. Here's an example of that I mean.
> 
> If a user types "get cookie from table" it calls upon the $body.get_from_cmd
> "get|take <any> from <descendant of $location>"          $body.get_from_cmd
> 
> But what if I made a new descendat of $location called $tray, and I made
> $tray.get_from_cmd that I wanted to be called instead of $body.get_from_cmd
> when someone tries to take something from a $tray or one of its descendants.
> Can I simply @ac the following:
> 
> "get|take <any> from <descendant of $tray>"          $tray.get_from_cmd
> 
> or is there a better way to do that? Also, what is the best way to do it for
> a specific object, say $thing_23, as opposed to a parent object that will
> have many children. You know, you try to 'get' a ball ($thing_23) and
> instead of you picking it up, it rolls away.

The order for commands in ColdCore is currently:

1. user shortcuts
2. user local commands
3. location shortcuts
4. location local commands
5. any remote command
6. exits

(this can be seen in $command_parser.parse)

Originally, the parser was supposed to take the 'best' match, but I'm
not sure if it is doing that currently.  It does take the best match
within a subscope--that is at each step of the way if multiple matches
are found it'll take the best of the set.  So in step 2 if there are
three user commands which match it'll take the best of the three.  But
it will not take a remote command if it matches better than the user
commands.  This could be improved upon.

As for your problem, the initial reaction would be to say to add:

  "get|take <any> from <this>" to $try.get_from_cmd

This makes it a remote command, rather than a local command (the
<this> part does).  However, it will conflict with the command on
$body, and since it is a local command it'll get called first (it is
found in step #2).

Frankly, the body command is in the wrong place, and should
instead be on $thing--I recall putting it on body for a reason,
however... probably thing frobs, they broke a bunch of stuff...

-Brandon