From the NannyMUD documentation

LAST CHANGE

2001-01-06

FUNCTION


NAME

        id - test for identity of an object

LOCATION

Most objects.

SYNTAX

int id(string str);

DESCRIPTION

	Perhaps the most called local function in the mudlib, the 'id'
	function is used most frequently when a player attempts to look
	at something.  A non-zero value means the object responds to the
	name passed to it.

RETURN VALUES

	If 'id' returns a non-zero value, it means the object is identified
	by the string passed to the function.

NOTE

	Many parts of the mudlib check id() in objects very frequently.
	Bugs and inefficiencies are thus multiplied many fold when they
	occur in id().  However, it is an easy function to use and rarely
	will anyone cause a bug with it.

	Many of the standard mudlib objects (simple_weapon.c, monster.c, etc)
	have standard local functions for setting up the identities of
	objects.  Most commonly these include: set_name() and add_alias().
	Generally you should use them if they are available, instead of
	writing your own 'id' function.

EXAMPLE

        In an imaginary weapon:

	int id(string str) {
	    return str == "sword" || str == "long sword";
        }

	or with the verb 'swing' in a silly object:

	int id(string str) { return str == "cat" || str == "feline"; }

	void init() { add_action("verb_swing", "swing"); }

	int verb_swing(string str) {
	   if( !id(str) ) {
              /* Player did not type 'swing cat'.  Return 0 lets the action
		 'fall' through in case other objects define the action
		 'swing' */
	      notify_fail("Swing what?\n"); 
              return 0;
           }
	   ...
        }

SEE ALSO

        long in lfun/basic/long

SEE ALSO

        add_action in efun/object_related/add_action

SEE ALSO

        set_name in lfun/basic/set_name
        set_name in obj/quest_obj
        set_name in std/basic/stationary

SEE ALSO

        add_alias in std/basic/stationary