ID(L)

NAME
	id - test for identity of an object 

SYNOPSIS
	int id(string str);

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

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.

NOTES
	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 (weapon.c, monster.c, etc)
	have standard local functions for setting up the identities of
	objects.  Most commonly these include: set_name(), set_alias(),
	and set_alt_name(); some newer files have set_aliases() to which
	an array of strings can be passed.  Generally you should use these
	if they are available, instead of writing your own 'id' function.

EXAMPLES
        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(L), add_action(E), set_name(L), set_aliases(L)

Help topics available:
add_hook add_weight can_put_and_get clean_up drop
extra_look get heart_beat id init
init_arg is_armour is_money is_weapon long
query_auto_load query_hook query_long query_name query_prevent_move_from_statue
remove_hook reset set_long set_name set_short
short

[START|BACK ]




[ NannyMuds main page | FAQ | Contact us ]

You are guest number 88 since January 2020.
This file was last modified: June 2000.