NAME basic.c - basic function used by _all_ objects. SETUP FUNCTIONS set_short set_long add_item remove_item add_property remove_property add_command remove_command add_item_cmd remove_item_cmd QUERY FUNCTIONS short id query_long long query_item_map query_property SPECIAL PROPERTIES __remote: see eval() simplemore: feed long() through simplemoer temp_*: Any property beginning with temp_ will be removed automatically next reset. OTHER FUNCTIONS eval reset NOTA BENE Please do not redefine long(), redefine query_long() instead. ======================================================================= NAME eval - process a value SYNTAX mixed eval(mixed value,mixed optional_argument) DESCRIPTION This is an internal function called from various query functions such as short() etc. It allows you to let short return the value of a function call instead of just a string. If the value is of the form: "@function_name(argument)" or "@object_name->function_name(argument)" The given function will be called with these three arguments: 1) the string given as 'argument' above. 2) the optional argument to eval() 3) this_object() If the first form is given (no object_name) the function will be called in query_property("__remote") if set, and in this_object() otherwise. Note that expand_file_name is called on the object_name, which means that you can write filenames as '../armourdaemon' if you like. EXAMPLE set_short("@/std/foo->get_short()"); ======================================================================= NAME set_short - set the short description SYNTAX void set_short(string short_desc); DESCRIPTION Set the value returned by short(). eval is called on this value. ======================================================================= NAME set_long - set the long description SYNTAX void set_long(string long_desc); DESCRIPTION Set the value returned by query_long(), eval is called on this value. Note that that you should either linebreak this string yourself or completely leave out all newlines, in whioch case set_long will linebreak it to 78 chars/line for you. Also, if you set the property "simplemore" long desc will be fed through simplemore when you look at the object. ======================================================================= NAME add_item - add/change an item SYNTAX void add_item(mixed item, string description); or void add_item(mapping items); DESCRIPTION This function adds an 'item' so you can look at it. If the item in question already exists it will be redefined. If the first argument is an array, an item will be added for each string in that array with the same description. The description is passed to eval, when someone looks at it, with the name of the item as optional_argument. The second syntax (giving a mapping as argument) removes all previous items and then sets the items to the new argument. Note that that you should either linebreak the description yourself or completely leave out all newlines, in whioch case add_item will linebreak it to 78 chars/line for you. NOTE Note that no periods or newlines will be appended to the description. Items MUST be lower case, because the 'look at' forces all characters to lower case. EXAMPLE add_item("snow","It is white.\n"); add_item(({"snowman","man"}),"He looks cold.\n"); ======================================================================= NAME remove_item - remove one or several items SYNTAX void remove_item(mixed item); DESCRIPTION This function removes an item (if it exists). Just as with add_item, the first argument can be an array, in which case all the items in that array will be removed. ======================================================================= NAME add_property - add/change/set properties SYNTAX void add_property(string property [, mixed value]); or void add_property(mapping properties); DESCRIPTION The first syntax adds or changes one property to have the given value. (Default is 1) The property deamon will be asked to add linked properties. The second syntax first removes all properties and then sets the properties that are present in the mapping. NOTA BENE Any property starting with temp_ will be removed next call to reset. EXAMPLE add_property("metal"); add_property((["metal":1])); ======================================================================= NAME remove_property - remove one or several properties. SYNTAX void remove_property(mixed property); DESCRIPTION The argument is a property or an array of properties to be removed, any linked properties will also be removed. ======================================================================= NAME add_command - add a command definition to this room SYNTAX void add_command(mixed command, mixed action) DESCRIPTION Command is one of the following: 1) A string to match exactly eg. "climb tree" 2) A verb + " %s" eg. "climb %s" 3) An array containing strings of type 1 or 2 Action is a value that will be passed to eval(), and the return value will be intepreted as follows: o If it is a string, it will be sent to /std/msg->msg() and the command will be considered successful. o If it is an integer other than zero, nothing will be written and the command will be considred successful. o If it is zero, the command will be considered unsuccessful. (ie. zero will be returned) EXAMPLES add_command( ({"climb tree","climb up"}), "You can't climb the tree.\n"); add_command("say %s","@say_cmd()"); NOTA BENE When using "@say_cmd(x)" or similar as action the eval() will be called with everything but the verb as second argument, that means that say_cmd will receive this as it's _second_ argument. The first argument will in this case be "x". SEE ALSO add_item_cmd, remove_command ======================================================================= NAME remove_command - the opposite of add_command SYNTAX void remove_command(string command) DESCRIPTION Removes a command previously added with add_command. Note that if you do add_command( ({"foo","bar"}), "action"); and then remove_command("foo") the action 'bar' will still be. SEE ALSO add_command ======================================================================= NAME add_item_cmd - add a command bound to an item SYNTAX void add_item_cmd(mixed verb, string item, string action) DESCRIPTION This function works similarly to add_command, except it binds to a previously added item, with some smart defaults. Verb is string or an array of strings which will be used, item is a name of a previously added item, even if the item has several aliases, only one of them is needed. The argument 'action' works exactly as the action argument for add_command. If this funcion is used in something that inherits stationary.c "item" can also be the name of the object in which case the name or any of the aliases of the object will match if used with the verb. Item can also be an array of items, in which case the action will be added for each item in the array. EXAMPLES add_item(({"tree","oak tree","large oak"}),"Looks climbable.\n"); add_item_cmd("climb","tree","@climb_tree()"); BUGS You can't have an add_item_cmd and an add_command on the same verb. This function uses the _description_ of the item as an identification that means that if you have several items with the same description in the room, add_item_cmd might not work as it should on those items. SEE ALSO add_command, remove_item_cmd ======================================================================= NAME remove_item_cmd - the opposite of add_item_cmd SYNTAX void remove_item_cmd(mixed verb, string item) DESCRIPTION Removes a previously added item command, the arguments have the same function as the first two arguments to add_item_cmd. SEE ALSO add_item_cmd ======================================================================= NAME query_property - ask if a property is set SYNTAX mixed query_property(string prop, int truth) DESCRIPTION If called with no arguments, the function returns an array with the names of all properties that are set in the object. If called with one argument, the function returns the value of the property after running that value through eval(). If called with two arguments, the function returns the value of the property without running that through eval(). =======================================================================
Help topics available:
basic.doc | basic_lock.doc | basic_thing.doc | stationary.doc |
You are guest number 60 since February 2020.
This file was last modified: June 2000.