Arbitrary command

From TinyMUX
Revision as of 13:36, 29 November 2005 by Cheetah (talk | contribs) (Note on disabled commands)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You may define commands that are triggered whenever someone enters a command that matches the command template (wildcarding allowed). These commands are called arbitrary commands, user-defined commands, or $-commands (for how they are defined), and they are checked for only after the check for single-character commands, exits, and internal commands have been performed and have failed (so an arbitrary command that matches 'page *' will never be performed, unless the page command is disabled).

You define an arbitrary command by storing a string of the form '$<template>:<commandlist>' in an attribute of an object, then the command will be available to anyone who carries the object, is in the same room as the object, or is inside the object. Only use user-named attributes and VA-VZ for arbitrary commands, as many of the predefined attributes are not for arbitrary commands. <template> is the pattern to check for (it may contain wildcards), and <commandlist> is a semicolon-separated list of commands to perform. The text that the wildcard characters matched are available in the variables %0 through %9.


> @va testobj = $foobar *:"I was foobar'ed with %0.
> foobar xyzzy
testobj says "I was foobar'ed with xyzzy"

You can prevent individual attributes from being checked for $-commands with the command '@set <obj>/<attr> = no_command'. Attributes so set are reported with ($) following the attribute name when examined. The command '@set <obj>/<attr> = !no_command' clears the flag. Setting an object itself no_command will prevent all arbitrary commands from being checked. Many MUSHes set this on newly @created objects to save resources, so make sure to clear it if you want to set commands on an object.

You can also match a regular expression rather than wildcards.

The following attributes are never checked for $-commands: Alias Charges Desc Drop Fail Idesc Odesc Odrop Ofail Osucc Sex Succ.

See also: @set.

Relevant help files: help arbitrary commands, help arbitrary2. (Or help user-defined and help user-defined2 on PennMUSH.)