The Object Model
The Object Model
Everything in a MUSH is an object. Rooms, exits, things, and players are all objects in the database, distinguished by type but sharing a common set of properties. Understanding the object model is fundamental to building and programming in MUSH.
Object Types
There are four object types:
| Type | Created By | Purpose |
|---|---|---|
| Room | @dig | A location that contains other objects and has exits |
| Exit | @open | A link between rooms (or to other objects) |
| Thing | @create | An inanimate object that can be carried, dropped, and manipulated |
| Player | @pcreate / create | An animate object controlled by a human |
The type letter appears after the dbref in examine output: R for room, E for exit, P for player, and no letter for things.
Dbrefs
Every object has a unique database reference number (dbref), written as # followed by a number: #0, #1, #1234. Dbrefs are assigned sequentially when objects are created and are recycled when objects are destroyed.
Special dbrefs:
| Dbref | Meaning |
|---|---|
#0 | The master room (Limbo) |
#1 | God—the first player, with absolute power |
#-1 | NOTHING—indicates no object (failed match, no location, etc.) |
#-2 | AMBIGUOUS—multiple objects matched a name |
#-3 | HOME—a symbolic reference to an object’s home location |
Because dbrefs are recycled, a dbref that referred to your favorite sword yesterday might refer to someone else’s room today if the sword was destroyed. Use objid() for persistent references—it includes a creation timestamp that detects recycled dbrefs.
Properties
Every object has these intrinsic properties:
- Name – the display name. Exits can have multiple semicolon-separated aliases.
- Location – where the object is. Rooms have no location (or are in
#-1). Exits are located in their source room. - Contents – a linked list of objects inside this one. Rooms contain things, players, and other objects. Players and things can contain things.
- Exits – a linked list of exits attached to this object (primarily rooms, but any object can have exits via
@open). - Home – where the object goes when sent home. Players have a home room. Things have a home location.
- Owner – the player who owns this object. Players own themselves.
- Parent – an optional parent object for attribute inheritance.
- Zone – an optional zone master object for group control.
- Flags – a set of boolean flags (DARK, STICKY, WIZARD, etc.).
- Powers – a set of granted capabilities (see Powers List).
- Attributes – named key-value pairs storing data and code.
Containment
The containment model is simple: every object (except rooms) is inside exactly one other object. This forms a tree:
Room #100
├── Player #5 (Bob)
│ ├── Thing #200 (sword)
│ └── Thing #201 (shield)
├── Thing #300 (fountain)
└── Exit #400 (north -> #101)
Objects move between containers via commands like get, drop, enter, leave, goto, and @teleport. Each movement triggers a sequence of messages and attribute actions (see Moving).
Attribute Inheritance
If an object has a parent (set with @parent), it inherits attributes from that parent. When the server looks up an attribute, it checks the object first, then the parent, then the parent’s parent, up to a configurable depth (usually 10 levels).
Inheritance is read-only: changing an attribute on the parent affects all children that don’t override it. Setting an attribute on a child creates a local copy that shadows the parent’s version.
Exits on parent objects also appear in children. This is how zone-wide global exits work.
The Object Lifecycle
- Creation:
@create,@dig,@open, or@pcreateallocates a dbref. The lowest available recycled dbref is used first; if none are available, a new one is allocated at the end of the database. - Active use: The object exists, can be examined, modified, and interacted with.
- Destruction:
@destroymarks the object as GOING. After a configurable delay (or immediately with/instant), the object becomes GARBAGE—its attributes are cleared and its dbref is available for recycling.
The SAFE flag protects objects from accidental destruction. The DESTROY_OK flag allows anyone who controls the object to destroy it without confirmation.
Related Topics: Object Types, Dbref, Attribute, Zones, Parent Objects.