Attribute

From TinyMUX
Jump to: navigation, search

An attribute is used to store data on an object in the MUX database. There are two types of attributes: predefined and user-defined. Most predefined attributes have an @-command to set them, while both kinds can be set with @set or &.

Names

Attribute names may only contain letters, numbers, and the characters: < -_.@#$^&*~?=+| >, and must start with a letter or . _ # ~. Attribute names are not case-sensitive or case-preserving.

Ownership

The attributes on an object may be owned independently from the object. Normally, the owner of the object owns all of its attributes.

Attribute flags

Individual attributes may have flags set on them, similar to object flags.

Flag Name Description
case (C) $-command matching will not be case-sensitive. Non-functional unless the 'R' flag is also set.
no_clone (c) (PennMUSH) This attribute will not be copied when the object is cloned.
const No one can modify this attribute. PennMUSH uses safe (S) for this.
no_command ($) The attribute is not checked when looking for $-commands. Note that the predefined attributes DESC, IDESC, ODESC, FAIL, OFAIL, SUCC, OSUCC, DROP, ODROP, SEX, and CHARGES are never checked.
dark Only God can see this see this attribute.
debug (b) (PennMUSH) Evaluation of this attribute is in debugging mode, as if the object's Debug flag were set during the attribute's evaluation.
god Only God can modify this attribute.
hidden (M) Only wizards and royalty can see this attribute. PennMUSH terms this mortal_dark and abbreviates it with (lower-case) m.
html (H) Emits from attr, oattr, aattr are not HTML escaped.
no_inherit (I) This attribute is not inherited by the children of the object. In PennMUSH, this attribute is abbreviated with (lower-case) i.
locked (+) The attribute is locked, it does not change ownership when the object is chowned and may not be modified.
noname (N) and nospace (S) (PennMUSH) When set on @o-message attributes (e.g. @ofailure), noname disables the prepending of the enactor's name to the message and nospace disables the insertion of a space between the enactor's name and the message.
private Only the attribute owner and wizards can see this attribute.
regexp (R) $-command matching on this attribute uses PCRE-style regular expressions.
veiled (V) (PennMUSH) The attribute is not shown when the object is examined (but is shown if the attribute is examined by name or wildcard). Useful for spammy data attributes.
visual (V) The attribute is visible to anyone who examines the object. The predefined attributes DESC, SEX, and LAST are always VISUAL. In PennMUSH, this attribute is abbreviated with (lower-case) v.
wizard (W) Only wizards can modify this attribute. PennMUSH abbreviates this with (lower-case) w.

Contents

An attribute can contain up to an LBUF of characters. Attributes matching certain patterns may have special properties:

  • An attribute beginning with a $ and containing a : is an arbitrary command.
  • An attribute beginning with a ^ and containing a : is a listen pattern on objects set MONITOR.

Attribute Trees

PennMUSH provides special magic to attributes that contain the backtick (`) character: they represent attribute trees, conceptually similar to the way that files and directories/folders are organized on computer filesystems. Attribute trees can be used to reduce spam when examining and to provide organized control over permissions for related attributes.

For example, the following attribute name would be a couple levels down in its tree:

CHAR`SKILLS`PHYSICAL

Attribute names may not start or end with the backtick, and may not contain two backticks in a row.

All attributes are either branch attributes or leaf attributes. A branch attribute is an attribute that has other branches or leaves beneath it; a leaf attribute is one that does not. Any attribute may act as a branch. If you try to create an unsupported leaf, branch attributes will be created as needed to support it.

Attribute trees and examine

Attribute trees provide two immediate benefits. First, they reduce spam when examining objects. The usual * and ? wildcards for attributes do not match the ` character; the new ** wildcard does. Some examples of using examine:

examine obj            displays top-level attributes (plus object header)
examine obj/*          displays top-level attributes
examine obj/BRANCH`    displays only attributes immediately under BRANCH
examine obj/BRANCH`**  displays entire tree under BRANCH
examine obj/**         displays all attributes of object

The same principles apply to lattr(), but @decompile obj is a special case, and displays all attributes.

Branch attributes will be displayed with a ` in the attribute flags on examine.

Attribute trees and access control

The second benefit of attributes trees is convenient access control. Attribute flags that restrict attribute access or execution (no_inherit, no_command, mortal_dark, wizard) propagate down attribute trees, so if a branch is set mortal_dark, mortals can not read any of its leaves or subbranches either. Attribute flags that grant access (e.g. visual) do NOT propagate down trees.

Attribute trees and @parent

Attribute trees interact with @parent. Children that wish to override a leaf attribute must also have their own (overriding) copy of all branches leading to that leaf. If a branch on the parent is no_inherit, it will not be inherited, regardless of any other flags that may be present. If a branch is inherited, the child object can not loosen any access restrictions to inherited attributes that are set by the parent (although it may loosen access restrictions to its own attributes on the same branch). The child object may impose stricter restrictions, however, and these may prevent access to inherited parent data.


See also: List of predefined attributes, Attribute permissions.

Server Differences

On TinyMUX, if an attribute name starts with _, it has the permission settings "wizard" and "hidden". TinyMUSH has a way to match attribute names to default permissions.

TinyMUX limits attribute names to 63 characters.