external next up previous contents index
Next: 10.4 Verbs and command Up: 10.3 Objects and properties Previous: 10.3 Objects and properties

Properties

 

Creation

``Properties'' are named slots in an object that can hold any kind of MOO Value (see section 10.5.1).

To create a property, you can '@property #obj.<name>' like in the following examples:

  @property dog.times 0
  @property dog.favorites {"Cats","Students", "bones"}
  @property dog.color "Dark white"

  @property & <object>.<prop-name>
  @property & <object>.<prop-name> <initial-value>

  Adds a new property named <prop-name> to the named object.
  The initial value is given by the second argument, if present; it
  defaults to 0.

  Normally, a property is created with permissions 'rc' and owned by
  whoever types the command.  However, you may also specify these
  explicitly

 @property <object>.<prop-name> <initial-value> <permissions>
 @property <object>.<prop-name> <initial-value> <permissions> <owner>

  Only wizards can create properties with owners other than themselves.

When you create an object, you always get always the parents properties by default.

Modification:

@set #obj.property to <something>.

Note that you can also use the editor to change the contents of the property. If the object is a list, you can use notedit.

Current versions of the MOO server initialize properties as 'clear'. This means that if a particular object is not the object that first defines a prop, then the prop will return the value of it's parent, and its parent's parent, (etc), until you reach the object where the prop is first defined. This means that if you change the value of the prop on an object that defines the prop, the value will change for any subsequent kids that have not had that value set.

The builtin is_clear_property() checks to see if a prop is clear, while the builtin clear_property() will return the prop back to it's cleared state. The best way to understand this is probably to just try it out with a few little eval experiments. Make a test object and don't describe it (doesn't matter what it's parent is). then type something like the following:

   ;is_clear_property(#test, "description")
This should return 1

Give your test obj a desc, and try the same eval. This time it should return a 0.

You can then take your test object and use

   ;clear_property(#test,"description")
to reset it's desc back to it's undescribed state.

Removing properties

    Syntax:  @rmproperty <object>.<prop-name>

Removes the named property from the named object. '@rmproperty' may be abbreviated as '@rmprop'.



Daniel K. Schneider
Thu Apr 17 12:43:52 MET DST 1997