http:// www.metamage.com / mush / croaker / chapter9.html

Croaker's TinyMUSH Manual

Last update: December 8, 2004

Author: Croaker

Editor: Josh Juran <wanderer@metamage.com>

URL: <http://www.metamage.com/mush/croaker/>


9. User Defined Commands

After a while it gets annoying to have to operate machines by talking to it. Either you have to talk to it out in the open, and contribute to noise pollution, or you have to go to the trouble of whispering to it. Also, it ruins the effect of having, say, a Mighty Sword of Slaying if you have to talk it into killing someone. User defined commands allows one to create objects that will react to direct commands.

9.1. How They Work

When you enter something in MUSH, it is scanned by the program to see if it is an internal command. If it is not, then all of the exits in the current room are scanned to see if any match. If this fails, then the command is sent out to all objects in the room for them to match against their user defined commands. In case no object acts on the command, the "Huh?" message is displayed.

The syntax of the user defined command is stored in an attribute (usually one of the general ones.) The format for a command definition is:

$string:action list

where string is the command string to set off the machine. It can contain wildcards, and will set the %1-%9 variables the same way they are set as if the LISTEN attribute matched the string.

Example: User defined commands

@create calculator
Created.

@va calculator=$*+*:"%0 plus %1 = add(%0.%1)
Set.

@vb calculator=$*+*:"%0 X %1 = mul(%0,%1)
Set.

drop calc
Dropped.

12+90
calculator says "12 plus 90 = 102"

23x3
calculator says "23 X 3 = 69"

look calculator
calculator(#7257)
You see nothing special.
VB:$*X*:"%0 X %1 = mul(%0,%1)
VA:$*+*:"%0 plus %1 = add(%0,%1)

9.2. Security Problems with User Defined Commands

As noted above, all commands that are not recognized as either an internal command or an exit are broadcast to all machines so that they can take a shot at matching the command. The problem is that mistyped commands are broadcast to all the machines in the room. This means that a bit more caution is called for if you really don't want people hearing what you are saying. If you should mistype a command like whisper, it is possible for a machine to record what you said, or relay it to its owner. There is no way, however, for a correctly typed whisper command to be intercepted.

Example:

@vc calc=$*:"Why did you type %0?
Set.

grwgrw
calculator says "Why did you type grwgrw?"

whusper shiva=something secret
calculator says "Why did you type whusper shiva=something secret?"


Last updated December 10, 2004 by Josh Juran
Metamage Labs