1.3. Objects

An object in LPC is a "thing" that encapsulates behavior (in the form of methods) and data (in the form of variables and properties). Most things on a mud are composed of objects since objects and manipulating objects are a convenient way to do simulation of a mud world. Rooms, armor, weapons, players, monsters, ... these are all implemented as objects on a mud.

LPC objects have a "lifecycle".

The driver calls the create() on an object to initialize the object. Any properties or variables should be set on the object here. If the object is a subclass of another object (i.e. it inherits from another object), then the create() function should call the superclass' create() function.

As a side note, your object doesn't have to have a create() function if it doesn't have any data to initialize.

When a living thing (anything with a heartbeat) comes in contact with an object (moves into a room, gets the object, ...), then the driver calls the object's init() function.

When an object is no longer needed or it is destroyed, then remove() is called on the object.

Finally, the destruct() function is called on the object which makes the instance of the object disappear completely never to be referred to or used again.