Your browser must have JavaScript enabled in order to view this page.
 >  >
 
Welcome Guest#9228 Login/register    Go to Bottom
Go to Top

Class: DpObject

SOURCE LOCATION:  /dpuniverse/std/DpObject.php

Class Overview

The standard object which is built upon by all other objects

Creates the following DutchPIPE properties:

  • string uniqueId - Unique Id for this instance, for example 'object_436'
  • integer resetTime - UNIX timestamp of next reset
  • string location - Location in dpuniverse, for example '/page/manual.php'
  • string sublocation - Optional sublocation, for example 'introduction'
  • int|float credits - Credits contained, integer or float depending on type, initially 0
  • string template - Optional replacement for dpdefault.tpl, absolute path on server
  • string title - Title for this object, "beer", used for object labels, etc.
  • string titleDefinite - Definite title for this object, "the beer"
  • string titleIndefinite - Indefinite title for this object, "a beer"
  • string titleType - Type of this object's title
  • string titleImg - URL for the avatar or other image representing this object
  • int titleImgWidth - Width of the title image in pixels, you can optionally set this by hand for extra speed but it is not mandatory
  • int titleImgHeight - Height of the title image in pixels, you can optionally set this by hand for extra speed but it is not mandatory
  • boolean isDraggable - Can we be dragged on the screen by a given user? Experimental
  • string body - HTML content of this object
  • integer creationTime - UNIX timestamp when this object instance was created
  • integer lastEventTime - UNIX timestamp of last event, used by cleanup mechanism
  • string navigationTrailHtml - HTML with a navigation trail for this page
  • int|float value - Monetary value, integer or float depending on type, initially 0
  • boolean isRemoved - TRUE if removed from universe but not destructed yet by PHP
  • integer lastActionTime - UNIX timestamp of last action performed by this object

DpProperties
   |
   --DpObject
LOCATED IN:  /dpuniverse/std/DpObject.php [line 102]
AUTHOR(S):   Lennert Stock <ls@dutchpipe.org>
LINK:  http://dutchpipe.org/manual/package/DutchPIPE
VERSION:  Release: 0.2.1
LICENSE:  DutchPIPE License
COPYRIGHT:  2006, 2007 Lennert Stock
METHODS:

Direct Descendants

Child Class Description
Note A small note that users can read
DpDrink A common drink which can be turned into beers, wine, etc.
DpPage A DutchPIPE enabled web page
DpLiving An object which is "alive", common code shared between users and NPCs
DpHeap A heap of credits, stones, etc., represented by one object

Inherits

Inherited Methods

INHERITED FROM:  DpProperties
void   DpProperties::coinherit()   "Coinherit" a class located at the given pathname
mixed   DpProperties::getDpProperty()   Directly retrieve the value of an existing DutchPIPE property
boolean   DpProperties::isDpProperty()   Determines if a property is defined in this object
void   DpProperties::removeDpProperties()   Removes properties and coinherits
void   DpProperties::setDpProperty()   Directly set the value of an existing DutchPIPE property
void   DpProperties::__call()   Handles set and get methods for properties using PHP member overloading
mixed   DpProperties::__get()   Gets the value of a DutchPIPE property using PHP member overloading
boolean   DpProperties::__isset()   Determines if a property is defined in this object using PHP member overloading
void   DpProperties::__set()   Sets the value of a DutchPIPE property using PHP member overloading
void   DpProperties::__unset()   Unsets the given DutchPIPE property using PHP member overloading

Methods Summary

void   __destruct()   Called by PHP when this object is destroyed, handles events
void   addAction()   Adds an action to the object
void   addId()   Adds one or more ids for this object
void   addItem()   Adds an examinable 'item' to this object
void   addMapAreaAction()   Adds an action to a map area so it becomes clickable there
void   addValidClientCall()   Makes the given method callable from the DutchPIPE client
void   createDpObject()   Sets this object up at the time it is created
void   event()   Reports an event
void   eventDpObject()   Reports an event
array   getActionData()   Gets data of one, multiple or all actions
void   getActionsMenu()   Tells the current user the HTML with the action menu for this object
string   getAppearance()   Gets the HTML "appearance" of this object
string   getAppearanceInventory()   Gets the HTML "appearance" of all objects in this object's inventory
string   getAppearanceTitle()   Gets the graphical appearance in HTML for this object
string   getBody()   Gets the HTML content of this object
int|float   getCredits()   Gets the amount of credits in the inventory of this object
mixed   &getEnvironment()   Gets the object reference to the environment of this object
int|float   getHeapAmount()   Gets the amount of a given heap object
array   getIds()   Gets the array of ids for this object, or an empty array for no ids
array   &getInventory()   Gets an array with object references to all objects in our inventory
array   getItem()   Gets an array with data about an item
mixed   getItemDescription()   Gets the description of a given item
array   getItems()   Gets an array with all item data added to this object
mixed   getMapArea()   Gets data of one, multiple or all imagemap areas
array   getMapAreaActions()   Gets all map area actions for all areas or for a given area
string   getMapAreaHtml()   Gets HTML for all imagemaps or the given imagemap for inclusion in page
string   getNavigationTrailHtml()   Gets a HTML navigation trail for this object
array   &getTargettedActions()   Gets actions which can be performed on this object, for action menu
string   getTitle()   Gets the object's title with optional prefixes such as 'a' and 'the'
mixed   getTitleImgHeight()   Gets the height in pixels of the title image
mixed   getTitleImgWidth()   Gets the width in pixels of the title image
void   handleCleanUp()   Called by the universe object, checks if this object can be removed.
boolean   isDraggable()   Can we be dragged on the screen by the given user?
boolean   isId()   Checks if the given id is a valid id for this object
boolean   isPresent()   Checks if an object is present in this object's inventory
boolean   isValidClientCall()   May the given method be called in this object from the DutchPIPE client?
void   makePresent()   Makes sure an object is present in this object's inventory
int   moveDpObject()   Moves this object into the inventory of another object
boolean   performActionSubject()   Tries if a user action can be performed on this object
void   removeAction()   Removes the given action.
void   removeDpObject()   Removes this object from the universe
void   removeId()   Removes one or more ids for this object
void   removeMapAreaAction()   Removes a map area action
void   removeValidClientCall()   Removes the given method from callable methods from the DutchPIPE client
void   reportMove()   Reports graphical movement of this object to other objects
void   resetDpObject()   Resets this object
void   setBody()   Sets the HTML content of this object
boolean   setCredits()   Sets the amount of credits in the inventory of this object
boolean   setHeapAmount()   Sets a heap object of a given amount in this object
void   setIds()   Sets an array of names used to refer to this object
void   setMapArea()   Creates a new imagemap area which can be used by actions
void   setTimeout()   Calls the given method after the given number of seconds
void   setTitle()   Sets the title for this object, "beer", used for object labels, etc.
void   tell()   Tells data (message, window, location, ...) to this object

Methods

Destructor __destruct  [line 378]
void __destruct( )

Called by PHP when this object is destroyed, handles events

Called by PHP when this object is destroyed. removeDpObject should be called in this object to remove it from the universe. Don't use unset to remove objects. On a PHP level, __destruct will then be called in this object.

Calls the event method in this object and its environment, if any, when defined, using constants from events.php.

Triggers the EVENT_LEFT_INV event in the environment of this object with "from" ($this) and "to" (0) parameters: $environment->event(EVENT_LEFT_INV, $this, 0);

Triggers the EVENT_CHANGED_ENV event in this object with "from" (the environment) and "to" (0) parameters: $this->event(EVENT_CHANGED_ENV, $environment, 0);

If the object had no environment, the above two events are not called, instead the EVENT_CHANGED_ENV event is triggered in this object with only a "from" (0) parameter: $this->event(EVENT_CHANGED_ENV, 0);

Last, the EVENT_DESTROYING_OBJ event is triggered in this object: $this->event(EVENT_DESTROYING_OBJ);


addAction  [line 1691]
void addAction( mixed $actionMenu , mixed $actionVerb , mixed $actionMethod , [mixed $actionOperant = DP_ACTION_OPERANT_MENU] , [mixed $actionTarget = DP_ACTION_TARGET_SELF] , [mixed $actionAuthorized = DP_ACTION_AUTHORIZED_ALL] , [mixed $actionScope = DP_ACTION_SCOPE_ALL] , [mixed $mapArea = NULL] , [string $mapAreaAction = NULL]   )

Adds an action to the object

Use this method to have actions added to the menus you get when clicking on items (the "action menu"), and at the same time to add actions you can type. See DpLiving.php for some good examples.

Because of the complexity of this method, it has its own manual page. See Action System for further information.


PARAMETERS: mixed   $actionMenu  title of clickable menu item
mixed   $actionVerb  alternative verb to type
mixed   $actionMethod  method called to perform action
mixed   $actionOperant  on who/what does it have effect?
mixed   $actionTarget  where should menu item appear?
mixed   $actionAuthorized  who may perform this action?
mixed   $actionScope  who sees action to begin with?
mixed   $mapArea  imagemap area id or definition
string   $mapAreaAction  specific action to use
ACCESS:  public
SEE:  DpObject::removeAction(), DpObject::getActionData(), DpObject::getActionsMenu(), DpObject::setMapArea()
TUTORIAL:  Action System
addId  [line 844]
void addId( string|array $id   )

Adds one or more ids for this object

A single id can be added at a time, or an array with ids can be given, or multiple arguments can be given (strings or array of strings).


PARAMETERS: string|array   $id  name string or array of name strings
SEE:  DpObject::setIds(), DpObject::removeId(), DpObject::getIds(), DpObject::isId()
addItem  [line 1546]
void addItem( mixed $item , string $description , [mixed $method = NULL] , [mixed $mapArea = NULL] , [mixed $mapAreaActionMenu = NULL]   )

Adds an examinable 'item' to this object

'Items' in objects allow you to perform some basic actions, such as examine, without making new objects.

For example, consider this page with the following description:
You are in front of a house. You see a sign.

The following call will make the house examinable:

  1. add_item('house''It is a big, brick house.<br />');

The $item can be an identifier string or an array with strings with identifiers, for example array('house', 'brick house'). Such aliases can be used from the command line, for example 'examine brick house'.

The $description should be a string with the textual description.

The $method is optional and should be a string containing a method or an array with two elements: an object to call and a string with the method. This method is called at runtime to obtain the description. It should be defined like this:

  1. function <methodName>($item)
and return a string.
When the $description is NULL, only the result from this method will be shown. With the $description is a normal string, the result of the method is appended. When the description has the %s token in it, the result of the method is inserted there. Example:
  1. add_item('door''A solid door. It is %s.''getOpenOrClosed');

The optional $mapArea can be given to make this item accessible on an imagemap, so people can click on it to examine it. Otherwise the item can only be examined by using the command line. It should be a map area id if you set one earlier with setMapArea, or an array with the arguments to setMapArea to define a new one (see setMapArea documentation for more information).

If a map area is used, the action on the imagemap is labelled 'examine'. This can be overruled by supplying $mapAreaActionMenu, which should be a string with an alternative label.


PARAMETERS: mixed   $item  string or array of strings with item ids
string   $description  item description
mixed   $method  method for dynamic description
mixed   $mapArea  imagemap area id or definition
mixed   $mapAreaActionMenu  action to appear on menu
SEE:  DpObject::getItem(), DpObject::getItemDescription(), DpObject::getItems(), DpObject::addAction(), DpObject::setMapArea()
SINCE:  DutchPIPE 0.2.0
addMapAreaAction  [line 2596]
void addMapAreaAction( string $mapAreaId , string $actionMenuTitle , string $action , [string $actionVerb = NULL] , [string $actionVerbKey = NULL]   )

Adds an action to a map area so it becomes clickable there

Creates a menu item labelled $actionMenuTitle on the imagemap area with id $mapAreaId. When clicked, executes $action for that user.

Can optionally be associated with an existing action by giving an $actionVerb and $actionVerbKey. Normal map area menu actions always appear. By associating it to a regular action, all its settings such as scope, target and authorization are used. Use addAction to set up such a map area action, as addAction will call addMapAreaAction with the right verb and verb key (a verb key is needed because there can be multiple indentical verbs).


PARAMETERS: string   $mapAreaId  id of area in imagemap
string   $actionMenuTitle  title of menu item
string   $action  action executed when clicked
string   $actionVerb  optional associated verb
string   $actionVerbKey  optional index of this verb
SEE:  DpObject::setMapArea(), DpObject::getMapArea(), DpObject::removeMapAreaAction(),
SINCE:  DutchPIPE 0.2.0
addValidClientCall  [line 3049]
void addValidClientCall( string $methodName   )

Makes the given method callable from the DutchPIPE client

PARAMETERS: string   $methodName  method to add
ACCESS:  protected
SEE:  DpObject::removeValidClientCall(), DpObject::isValidClientCall()
SINCE:  DutchPIPE 0.4.0
createDpObject  [line 315]
void createDpObject( )

Sets this object up at the time it is created

An empty function which can be redefined by the class extending on DpObject. When the object is created, it has no title, HTML body, etc., so here methods such as $this->setTitle() are called. Building blocks extending on DpObject may define their own create function. For example, DpPage defines createDpPage.


SEE:  DpObject::resetDpObject()
REDEFINED AS:   Note::createDpObject(): Sets up the object at object creation time
DpPage::createDpObject(): Creates this page
event  [line 2866]
void event( object $name , mixed $args   )

Reports an event

Called when certain events occur, given with $name. The property lastEventTime is set to a unix time stamp. Calls eventDpObject.


PARAMETERS: object   $name  Name of event
mixed   $args  One or more arguments, depends on event
eventDpObject  [line 2882]
void eventDpObject( object $name , mixed $args   )

Reports an event

Called when certain events occur, given with $name.


PARAMETERS: object   $name  Name of event
mixed   $args  One or more arguments, depends on event
SINCE:  DutchPIPE 0.2.0
REDEFINED AS:   DpPage::eventDpObject(): Reports an event
DpLiving::eventDpObject(): Reports an event
getActionData  [line 1827]
array getActionData( [boolean $actionVerb = NULL] , [ $actionNr = NULL] , integer &$actionNr   )

Gets data of one, multiple or all actions

Without arguments, an array is returned with each element of pair consisting of: verb => array(menulabel, method, operant, target, authorized, scope) with operant one of DP_ACTION_OPERANT_, target one of DP_ACTION_TARGET_, authorized one of DP_ACTION_AUTHORIZED_ and scope one of DP_ACTION_SCOPE_ from dpuniverse/include/actions.php, for example: 'read' => array('read me!', 'actionRead', DP_ACTION_OPERANT_MENU, DP_ACTION_TARGET_SELF, DP_ACTION_AUTHORIZED_ALL, DP_ACTION_SCOPE_ALL)

You can narrow the result set down by supplying a verb, in which case an array with one or more results is returned, or FALSE if the given verb is not defined as an action.

Narrow it down further by giving a number, usually 0, to get the data at the index of the array you would get without supplying a number.


PARAMETERS: boolean   $actionVerb  alternative command to type
integer   &$actionNr  index of the verb in alternatives list
   $actionNr 
RETURNS:  array  array with actions, can be empty
SEE:  DpObject::addAction(), DpObject::removeAction(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.1
getActionsMenu  [line 1853]
void getActionsMenu( )

Tells the current user the HTML with the action menu for this object

getAppearance  [line 1226]
string getAppearance( [int $level = 0] , [boolean $include_div = TRUE] , [object $from = NULL] , [string $displayMode = 'abstract'] , [boolean $displayTitlebar = TRUE] , [boolean $elementId = 'dppage']   )

Gets the HTML "appearance" of this object

Gets HTML to represent the object to another objects. That is, other objects call this method in order to "see" it, and HTML is returned. How an object is seen depends on how the object is related to the object that is viewing it in terms of "physical" location.

In other words, a level of 0 means this object is seen by something in its inventory (a user sees a page). Level 1 means this object is seen by an object in its environment (a user sees another user). Level 2 means this object is in the inventory of the object that is seeing it.


PARAMETERS: int   $level  level of visibility
boolean   $include_div  include div with id around HTML?
object   $from  experimental
string   $displayMode  'abstract' or 'graphical'
boolean   $displayTitlebar  display title bar for pages?
boolean   $elementId  to be used as html element id
RETURNS:  string  HTML "appearance" of this object
ACCESS:  public
SEE:  DpObject::getAppearanceTitle()
getAppearanceInventory  [line 1466]
string getAppearanceInventory( [int $level = 0] , [boolean $include_div = TRUE] , [object $from = NULL] , [string $displayMode = 'abstract'] , [ $displayTitlebar = TRUE] , [ $elementId = 'dppage']   )

Gets the HTML "appearance" of all objects in this object's inventory

Gets HTML to represents the all objects in this object's inventory using getAppearance.


PARAMETERS: int   $level  level of visibility of this object
boolean   $include_div  include div with id around HTML?
object   $from  expiremental
string   $displayMode  'abstract' or 'graphical'
   $displayTitlebar 
   $elementId 
RETURNS:  string  HTML "appearances" of this object's inventory
getAppearanceTitle  [line 1405]
string getAppearanceTitle( object &$user   )

Gets the graphical appearance in HTML for this object

Returns the HTML with the image and the title of the object. The method filterAppearance($level, &$from, $appearance, &$user) is called in the environments of the object if defined. $level is 1, $from is an array starting with this object, followed by elements defining a path to the current object being called, $appearance the default appearance HTML and $user the user for which we're getting the appearance of the object. If you define it, it should return a string with the HTML for the appearance, just like getAppearanceTitle does itself.


PARAMETERS: object   &$user  performer of actions
RETURNS:  string  the graphical appearance in HTML for this object
SEE:  DpObject::getAppearanceTitle()
SINCE:  DutchPIPE 0.3.0
getBody  [line 1108]
string getBody( )

Gets the HTML content of this object

RETURNS:  string  HTML content of this object
ACCESS:  public
SEE:  DpObject::setBody()
REDEFINED AS:   Login::getBody(): Logs out users, gets the HTML content of this object
getCredits  [line 3037]
int|float getCredits( )

Gets the amount of credits in the inventory of this object

RETURNS:  int|float  amount of credits
SEE:  DpObject::setCredits()
SINCE:  DutchPIPE 0.2.0
getEnvironment  [line 766]
mixed &getEnvironment( )

Gets the object reference to the environment of this object

RETURNS:  mixed  object reference or FALSE for no environment
getHeapAmount  [line 3002]
int|float getHeapAmount( string $idProperty   )

Gets the amount of a given heap object

PARAMETERS: string   $idProperty  unique property to identify heap object
RETURNS:  int|float  amount, depends on heap type
SINCE:  DutchPIPE 0.2.0
getIds  [line 899]
array getIds( )

Gets the array of ids for this object, or an empty array for no ids

RETURNS:  array  array of name strings
SEE:  DpObject::setIds(), DpObject::addId(), DpObject::removeId(), DpObject::isId()
getInventory  [line 778]
array &getInventory( )

Gets an array with object references to all objects in our inventory

If this object contains no other objects, an empty array is returned.


RETURNS:  array  object references to objects in our inventory
getItem  [line 1585]
array getItem( string $item   )

Gets an array with data about an item

An array is returned with two elements: the item description and the item method. Either can be NULL. If the item was not found, FALSE is returned.


PARAMETERS: string   $item  the item id to search for
RETURNS:  array  array with data about the given item, or FALSE
SEE:  DpObject::addItem(), DpObject::getItemDescription(), DpObject::getItems(), DpObject::addAction(), DpObject::setMapArea()
SINCE:  DutchPIPE 0.2.0
getItemDescription  [line 1617]
mixed getItemDescription( string $item   )

Gets the description of a given item

Returns the description of the given item, or FALSE if no such item was found. Items can be added with a method to call (see addItem), here this method is processed.


PARAMETERS: string   $item  the item id to search for
RETURNS:  mixed  string with description or FALSE
SEE:  DpObject::addItem(), DpObject::getItem(), DpObject::getItems(), DpObject::addAction(), DpObject::setMapArea()
SINCE:  DutchPIPE 0.2.0
getItems  [line 1664]
array getItems( )

Gets an array with all item data added to this object

RETURNS:  array  all items added to this object
SEE:  DpObject::addItem(), DpObject::getItem(), DpObject::getItemDescription(), DpObject::addAction(), DpObject::setMapArea()
SINCE:  DutchPIPE 0.2.0
getMapArea  [line 2557]
mixed getMapArea( [string $mapName = NULL] , [string $mapAreaId = NULL]   )

Gets data of one, multiple or all imagemap areas

If no arguments are given data of all imagemap areas is returned. If an imagemap name is given, all data for that map is returned, or FALSE if the imagemap is not defined. If both the map name and an id of the area in the map are given, data for that area is returned, or FALSE if not defined.


PARAMETERS: string   $mapName  name of imagemap
string   $mapAreaId  id of area in imagemap
RETURNS:  mixed  array with imagemap areas, can be empty, or FALSE
SEE:  DpObject::setMapArea(), DpObject::addMapAreaAction(), DpObject::removeMapAreaAction(), DpObject::getMapAreaActions(), DpObject::getMapAreaHtml(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
getMapAreaActions  [line 2653]
array getMapAreaActions( [string $mapAreaId = NULL]   )

Gets all map area actions for all areas or for a given area

PARAMETERS: string   $mapAreaId  id of area in imagemap
RETURNS:  array  array with map area data, can be empty
SEE:  DpObject::setMapArea(), DpObject::getMapArea(), DpObject::addMapAreaAction(), DpObject::removeMapAreaAction(), DpObject::getMapAreaHtml(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
getMapAreaHtml  [line 2675]
string getMapAreaHtml( [string $mapName = NULL]   )

Gets HTML for all imagemaps or the given imagemap for inclusion in page

Constructs the right HTML with <map> and <area> tags and onclick events. Returns an empty string of no map data was found. Used by getBody.


PARAMETERS: string   $mapName  name of imagemap
RETURNS:  string  HTML for one or more imagemaps, or empty string.
SEE:  DpObject::getBody(), DpObject::setMapArea(), DpObject::getMapArea(), DpObject::addMapAreaAction(), DpObject::removeMapAreaAction(), DpObject::getMapAreaActions(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
getNavigationTrailHtml  [line 1491]
string getNavigationTrailHtml( )

Gets a HTML navigation trail for this object

By default, a 'Home' link is always present.


RETURNS:  string  HTML for navigation trail
REDEFINED AS:   DpPage::getNavigationTrailHtml(): Gets HTML with a navigation trail for this page
getTargettedActions  [line 2050]
array &getTargettedActions( object &$user , [array $levels = NULL] , [string $mapAreaId = NULL]   )

Gets actions which can be performed on this object, for action menu

Gets an array with actions which can be performed on this object, so we can make a menu when hovering over the object image with the mouse. This includes actions that are defined by other objects but appear in this object's action menu.

An array is returned, empty if there are no menu actions found, with key-value pairs. Each key is the (first) menu title associated with the action pair, each value an array of three elements: the verb, the "operant" as defined with addAction and a boolean indicating whether this menu item is ghosted.


PARAMETERS: object   &$user  user getting the menu
array   $levels  current path of user in (sub)menu
string   $mapAreaId  id of area in imagemap
RETURNS:  array  array with menu actions, can be empty
SEE:  DpObject::getActionsMenu()
getTitle  [line 1019]
string getTitle( [string $type = NULL]   )

Gets the object's title with optional prefixes such as 'a' and 'the'

Gets the title as set with setTitle, for example "barkeeper" if no $type is given.

If $type is DPUNIVERSE_TITLE_TYPE_INDEFINITE, "a ..." or "an ..." is put in front if the object's title type has been set to indefinite. So for a barkeeper this returns "a barkeeper", for me it returns "Lennert".

If $type is DPUNIVERSE_TITLE_TYPE_DEFINITE, "the" is put in front if the object's title type is not DPUNIVERSE_TITLE_TYPE_NAME. So for a barkeeper this returns "the barkeeper", for me it returns "Lennert".


PARAMETERS: string   $type  noun type, use the constants above
RETURNS:  string  the object's title
ACCESS:  public
getTitleImgHeight  [line 3103]
mixed getTitleImgHeight( )

Gets the height in pixels of the title image

RETURNS:  mixed  Integer with height in pixels, FALSE for unknown
SEE:  DpObject::getTitleImgWidth()
SINCE:  DutchPIPE 0.4.1
getTitleImgWidth  [line 3088]
mixed getTitleImgWidth( )

Gets the width in pixels of the title image

RETURNS:  mixed  Integer with width in pixels, FALSE for unknown
SEE:  DpObject::getTitleImgHeight()
SINCE:  DutchPIPE 0.4.1
handleCleanUp  [line 2897]
void handleCleanUp( )

Called by the universe object, checks if this object can be removed.

To save some memory, the universe object will call this method in objects with no environment, which haven't been referenced for a while.

If no users or special object using the isNoCleanUp property are present, the object and all of its inventory is destroyed.


SINCE:  DutchPIPE 0.2.0
isDraggable  [line 2932]
boolean isDraggable( object &$by_who   )

Can we be dragged on the screen by the given user?

Experimental mouse dragging of objects.


PARAMETERS: object   &$by_who  subject that wants to drag us
RETURNS:  boolean  TRUE if $by_who may drag us, FALSE otherwise
SINCE:  DutchPIPE 0.2.0
isId  [line 918]
boolean isId( string $id , [string $checkWithArticle = TRUE]   )

Checks if the given id is a valid id for this object

For example, a barkeeper object was set up like this: $this->addId('barkeeper'); Now isId('barkeeper') called in this object will return TRUE, but 'the barkeeper' and 'a barkeeper' will also return TRUE. The disable the last behaviour, set $checkWithArticle to FALSE.


PARAMETERS: string   $id  name string to check
string   $checkWithArticle  also check ids with articles
RETURNS:  boolean  TRUE if the id is valid, FALSE otherwise
SEE:  DpObject::setIds(), DpObject::addId(), DpObject::removeId(), DpObject::getIds()
REDEFINED AS:   DpHeap::isId(): Checks if the given id is a valid id for this object
isPresent  [line 683]
boolean isPresent( mixed $what   )

Checks if an object is present in this object's inventory

If $what is a string, searches for an object with that id. If $what is an object, searches for that object. Searches are done in the inventory of this object.


PARAMETERS: mixed   $what  string (id) or object to search for
RETURNS:  boolean  TRUE if $what is in our inventory, FALSE otherwise
isValidClientCall  [line 3076]
boolean isValidClientCall( string $methodName   )

May the given method be called in this object from the DutchPIPE client?

PARAMETERS: string   $methodName  method to check
RETURNS:  boolean  TRUE if the method can be called, FALSE otherwise
SEE:  DpObject::addValidClientCall(), DpObject::removeValidClientCall()
SINCE:  DutchPIPE 0.4.0
makePresent  [line 717]
void makePresent( mixed $what , [int $number = 1] , [boolean $mustBeHere = TRUE] , [boolean $moveHere = FALSE]   )

Makes sure an object is present in this object's inventory

Replenishes this object's inventory up to $number instances of $what. This method is usually called from the reset method of pages and npc's.

If $what is a string, searches for an object with that id. If $what is an object, searches for that object. Searches are done in the inventory of this object.

A $number can be given to search for more objects instead of just one. For example, it could check for the presence of 5 roses, and if there are only 3, create another 2.

If $mustBeHere is FALSE (it is TRUE by default), it will not replenish objects which are still in another part of the universe, instead of having been destroyed. For example, the 2 missing roses could have been taken by a user who is now on another page, and with this argument set to FALSE, no extra objects will be created.

If $mustBeHere is TRUE, $moveHere can be set to TRUE (it is FALSE by default) to move objects which still exist but are located in another part of the universe, back to this object, its original location.


PARAMETERS: mixed   $what  string (id) or object to search for
int   $number  number of such objects to search for
boolean   $mustBeHere  search only here for object?
boolean   $moveHere  replenish from objects elsewhere?
moveDpObject  [line 453]
int moveDpObject( mixed &$target_ob , [boolean $simple = FALSE]   )

Moves this object into the inventory of another object

PARAMETERS: mixed   &$target_ob  path or object to move into to
boolean   $simple  skip some checks
RETURNS:  int  TRUE for success, an error code for failure
REDEFINED AS:   DpHeap::moveDpObject(): Moves this object into the inventory of another object
performActionSubject  [line 2737]
boolean performActionSubject( string $action , object &$living   )

Tries if a user action can be performed on this object

When a user doesn't use the action menu, but gives a command such as 'take beer', or when an NPC performs an action, the system doesn't know which object defines the action. Therefore, it calls this method in all objects which are eligable to perform this action. Objects are searched for, in this order, in the object performing the action, its inventory, in its environment, and the environment itself.

performActionSubject returns TRUE if the action was completed by this object, or FALSE if this action was not directed at this object, in which case the system will try the next object, if any.


PARAMETERS: string   $action  the complete input string
object   &$living  user or npc performing the action
RETURNS:  boolean  TRUE for action completed, FALSE otherwise
ACCESS:  public
removeAction  [line 1754]
void removeAction( boolean $actionVerb , [string $mapAreaId = NULL]   )

Removes the given action.

Removes the action associated to the given $actionVerb. If the action was linked to an imagemap area, provide the area id with $mapAreaId to delete this information as well.


PARAMETERS: boolean   $actionVerb  alternative command to type
string   $mapAreaId  imagemap area id
ACCESS:  public
SEE:  DpObject::addAction(), DpObject::getActionData(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
removeDpObject  [line 399]
void removeDpObject( )

Removes this object from the universe

The object is destroyed and no longer part of the universe. Don't use unset to remove objects. Removes the object from browsers viewing the same environment. On a PHP level, __destruct will then be called in this object.


removeId  [line 873]
void removeId( string|array $id   )

Removes one or more ids for this object

A single id can be removed at a time, or an array with ids can be given, or multiple arguments can be given (strings or array of strings).


PARAMETERS: string|array   $id  name string or array of name strings
SEE:  DpObject::setIds(), DpObject::addId(), DpObject::getIds(), DpObject::isId()
removeMapAreaAction  [line 2627]
void removeMapAreaAction( string $mapAreaId , string $actionMenuTitle , [string $action = NULL]   )

Removes a map area action

Either 1) the action menu title, 2) the executed action string when clicked (while the title is NULL) or 3) both can be given. Removes the first found match.


PARAMETERS: string   $mapAreaId  id of area in imagemap
string   $actionMenuTitle  title of menu item
string   $action  action executed when clicked
SEE:  DpObject::setMapArea(), DpObject::getMapArea(), DpObject::addMapAreaAction(), DpObject::getMapAreaActions(), DpObject::getMapAreaHtml(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
removeValidClientCall  [line 3061]
void removeValidClientCall( string $methodName   )

Removes the given method from callable methods from the DutchPIPE client

PARAMETERS: string   $methodName  method to remove
ACCESS:  protected
SEE:  DpObject::addValidClientCall(), DpObject::isValidClientCall()
SINCE:  DutchPIPE 0.4.0
reportMove  [line 2947]
void reportMove( )

Reports graphical movement of this object to other objects

Called by the client-side dpclient-js.php script after an object was dragged by a user. Coordinates are passed as 'x' and 'y' in a GET request and passed on to other users in the same environment.


SEE:  dpclient-js.php
SINCE:  DutchPIPE 0.2.0
resetDpObject  [line 345]
void resetDpObject( )

Resets this object

Called by this object at regular intervals as defined in dpuniverse-ini.php. An empty function which can be redefined by the class extending on DpObject. To be used to periodically do stuff such as alter the state of this object.


SEE:  DpObject::createDpObject()
REDEFINED AS:   DpPage::resetDpObject(): Resets this page
setBody  [line 1088]
void setBody( string $body , [string $type = 'text']   )

Sets the HTML content of this object

If this is a page, this defines the page content. For other objects, it defines what you see when examining the object or moving into the object (which makes the object behave like a page).

When a single argument is given, sets the HTML content to the given text.

Pairs of arguments can be given to set the content in other ways, with the second argument the type, and the first the data (what the data is depends on the type).

Types are: string (default, raw data) file (read content of given filename)

Examples: $this->setBody('Hello world'); $this->setBody('helloworld.html', 'file'); $this->setBody('Prefix', 'string', 'helloworld.html', 'file', 'Postfix', 'string')

When a file is read, the following strings are replaced by their corresponding constants: /dpclient.php, /page/ and /images/

Instead of text or a path, a method to call whenever the body property is requested can be given using an array two elements: an object and a method name. Depending on the type, the method should return text or a path.


PARAMETERS: string   $body  content data or method
string   $type  content type
ACCESS:  public
SEE:  DpObject::getBody()
setCredits  [line 3024]
boolean setCredits( int|float $credits   )

Sets the amount of credits in the inventory of this object

PARAMETERS: int|float   $credits  amount of credits
RETURNS:  boolean  TRUE for success, FALSE otherwise
SEE:  DpObject::getCredits()
SINCE:  DutchPIPE 0.2.0
setHeapAmount  [line 2978]
boolean setHeapAmount( string $pathname , string $idProperty , int|float $amount   )

Sets a heap object of a given amount in this object

PARAMETERS: string   $pathname  path to code from universe base path
string   $idProperty  unique property to identify heap object
int|float   $amount  amount, depends on heap type
RETURNS:  boolean  TRUE for success, FALSE otherwise
SINCE:  DutchPIPE 0.2.0
setIds  [line 827]
void setIds( array $ids   )

Sets an array of names used to refer to this object

Overwrites previous set ids. Ids are case insensitive and all turned into lowercase.


PARAMETERS: array   $ids  array of name strings
SEE:  DpObject::addId(), DpObject::removeId(), DpObject::getIds(), DpObject::isId()
setMapArea  [line 2531]
void setMapArea( string $mapName , string $mapAreaId , string $mapAreaShape , string $mapAreaCoords , [string $mapAreaAlt = '']   )

Creates a new imagemap area which can be used by actions

Creates an area for the imagemap $mapName. Make sure the right <map> and <area> HTML is included when this object is viewed. The image should have the following tag: usemap="#<map name>"

The id given with $mapAreaId can be used by others methods, such as addItem or addAction to refer to this area.

The shape of the imagemap given with $mapAreaShape is one of: circle, poly, rect See your HTML reference for a full explanation of these types.

The coordinates of the shape should be given with $mapAreaCoords, for example, the coordinates for a rectangle: 128,132,241,179 See your HTML reference for a full explanation about coordinates.

An optional tooltip can be shown when hovering over this area with the mouse with $mapAreaAlt.


PARAMETERS: string   $mapName  name of imagemap
string   $mapAreaId  id of area in this map
string   $mapAreaShape  cirlce, poly, rect
string   $mapAreaCoords  x,y,... (depends on shape)
string   $mapAreaAlt  mouse tooltip for this area
SEE:  DpObject::getMapArea(), DpObject::addMapAreaAction(), DpObject::removeMapAreaAction(), DpObject::getMapAreaActions(), DpObject::getMapAreaHtml(), DpObject::getActionsMenu()
SINCE:  DutchPIPE 0.2.0
setTimeout  [line 793]
void setTimeout( string $method , int $secs   )

Calls the given method after the given number of seconds

Use this to perform delayed method calls in this object. Note that functions such as get_current_dpuser() can be totally different when the method is called. Also note that the actual delay is not exact science.


PARAMETERS: string   $method  name of method to call in this object
int   $secs  delay in seconds
setTitle  [line 987]
void setTitle( string $title , [string $titleType = FALSE] , [string $titleImg = FALSE]   )

Sets the title for this object, "beer", used for object labels, etc.

This title is used for object labels, page titles, messages, et cetera. Objects are visualized using two mechanisms: the object's "title" and the object's "body". The title is used when the object is nearby, for instance in the environment of a user that sees it. The body is used when we're in the object (a page) or examining the object. In other words, the object's title is a very abstract way to describe the object when looking at it from a greater distance.

In plain language, this function controls the avatar or object image, and the label under it.

The $title should be a short description like "beer" without "a" or "the" in front.

The $title_img should be a URL to the image shown to represent this object.

The second argument, $type, should be a constant as defined in include/title_types.php and is used by the framework to, for example, construct lines such as "Lennert takes a cool, fresh beer" instead of "A Lennert takes a cool fresh, beer" or "The Lennert takes a cool, fresh beer".

DPUNIVERSE_TITLE_TYPE_INDEFINITE - the title is indefinite, "a beer" DPUNIVERSE_TITLE_TYPE_DEFINITE - the title is definite, "the hulk" DPUNIVERSE_TITLE_TYPE_NAME - the title is a name, "Lennert" DPUNIVERSE_TITLE_TYPE_PLURAL - the title is plural, "sweets" (not yet implemented)


PARAMETERS: string   $title  short description, "beer"
string   $titleType  noun type, use the constants above
string   $titleImg  URL to avatar or object image
ACCESS:  public
tell  [line 814]
void tell( string $data   )

Tells data (message, window, location, ...) to this object

Tells a message to this object, for instance a chat line. Handled by by default.


PARAMETERS: string   $data  message string
REDEFINED AS:   DpPage::tell(): Sends a message to all objects in this page, "makes sound or movement"
DpUser::tell(): Sends something to dpclient-js.php running on the user's browser
DpNpc::tell(): Tells data (message, window, location, ...) to this NPC

Documentation generated on Mon, 03 Sep 2007 22:20:18 +0200 by phpDocumentor 1.3.0RC6

Click me!
Guest#9228
 
 
 
  Go to Top
 
 
Input Field OptionsClose Input Field Go to Top
 
Legal Notices | Copyright © 2006, 2007 Lennert Stock. All rights reserved. Last update: Mon Sep 03 2007, 21:50 CET.