Attachments and Characteristics


Neil Rotstan

Version/Date: $Id: attachmentsandcharacteristics.aft,v 1.2 2001/12/31 02:09:03 willhelm Exp $


Attachments and characteristics are two ways of adding a little spice to your objects. Attachments allow you to literally attach one object to another object. For example, suppose you created a chest and you wanted to add a lock to it: you could do this by creating a lock object and attaching it to the chest. Attached objects don't show up in traditional inventory listings, but interactives can look at them just like any other object.

The most common use of attachments is to provide descriptions for the various nouns that occur in the description of an object. For example, suppose you had a room description along the lines of:

A dim and dusty passageway extends away to the south, leading into darkness and gloom. Cobwebs hang from the walls and small things crunch beneath your feet as you walk.

Most players will want to examine their surroundings and look at the different things described in the room description: the walls, cobwebs, darkness, and maybe even the things beneath the player's feet! Attachments can be used to easily provide descriptions for all of these things. In fact, the addAttachment method is specifically designed for this situation: you pass it a list of names by which the item can be referred and the description of the item:

   self.addAttachment(["passageway", "darkness", "gloom"],
	 "The passageway leads into darkness and gloom.")
   self.addAttachment(["walls", "cobwebs"],
	 "The walls are covered in sticky cobwebs!")
   self.addAttachment(["things"], "You're probably better off not knowing!")

If you already have an object that you'd like to use as an attachment (as in the lock example above), you can use the addAttachedObject method to attach it:

   self.addAttachedObject(myInterestingObject)

Characteristics are (usually single-line) descriptions that are appended to the long description of an object. For example, when an interactive dons some clothing, a characteristic is added to its long description:

He is wearing a green feathered hat and a flowing violet cape.

Note that characteristics are simply for show. Unlike attachments, there is no object that interactives can examine. If you want interactives to be able to examine items mentioned in a characteristic (such as the clothing mentioned above), you can also add those items as attachments. In fact, that's what happens when interactives wear clothing: a characteristic is added to the interactive describing the worn clothing and the clothes themselves are added as attachments so that other interactives can examine them. Characteristics and attachments compliment each other very well in this way.

For more details on attachments and characteristics, see the mudlib.core.Object class documentation.



This document was generated using AFT v5.077