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:
You are guest number 88 since January 2020.
This file was last modified: June 2000.