Background

This document is an attempt to provide examples of how to use the new object hierarchy. Please report any inaccuracies in this document to vender@plains.nodak.edu.

The Basics

This document assumes that the reader has seen Implementation.html and has access to a copy of the LambdaMOO programmer's manual.

Get and Set

Using the get and set functions is vitally important. Although the LambdaMOO server allows you to set property values directly, most of the time you should use get and set. This is especially true if the property you are manipulating is one of the local parameters for the game players. The reasons are

Scene Root

The server maintains a set of disjoint virtual spaces for player interaction. The typical LambdaMOO approach is to make each of these spaces an instance of class Room, and place the significant objects for that space directly in the room. Normally the location of each room is ignored, and typically set to $nothing. Because The server maintains a set of disjoint virtual spaces which the players move between. The normal LambdaMOO approach to this problem is to construct each of these spaces as a room, and effectively maintain a very shallow scene graph. The approach used by the Virtual Cell database is slighly different. So, to build a scene to display a cell process, the sequence of operations would be
  1. Create an instance of SceneRoot.
  2. Create an instance of Generic Room, and move it into the new SceneRoot. Adjust the properties of the room to display the correct VRML for the walls of the room as needed.
  3. Create appropriate instances of Generic (#242) as necessary to describe the things inside the room. Move each object into the room.

Building a reactive object

By default, server objects aren't interested in anything. In order to receive updates on another object, the verb add_interest is used, as in TargetObject:add_interest(InterestedObject) where normally an object will specify itself as the interested object.

When updates are received, the notify_change verb is called as InterestedObject:notify_change(What,property, new value). Similarly for say and emote, notify_say and notify_emote are called to propogate information. To explain how the code is intended to work, the next few sections will explain how "Generic Robot" was designed, and was tasks it expects.

Generic Robot

The following elements are essential for an object to be reactive

Generic VRML Scripting

At the moment, the most flexible model of input and output from a VRML object is implemented by the GenericIO subclass of Generic. Currently the following conventions are used

The simplest example of something useful in this case is the creation of a multiuser rotation control. Assuming the VRML looked something like


PROTO RotatorControl [
  eventOut SFRotation user_rotation_changed
] {
# Insert stuff here
}

RotatorControl {}

the appropriate vrml_output list would be { {"user_rotation", "SFRotation"} }.

The simplest example of using a simple PROTO node would be the case of a VRML file looking like

PROTO GenericJoint [
  eventIn SFRotation set_direction
] {
# Insert stuff here
# see http://caithness.cs.ndsu.nodak.edu/~vender/WRL/BradRoom/gen_joint.wrl
#
}

GenericJoint {}

The appropriate vrml_input would be { {"direction", "SFRotation"} }. The VRML object will initialize to the last known value from the server, and will follow any updates from that value. Any special animation of transitions must be hand coded in the VRML file, however.