From the NannyMUD documentation

LAST CHANGE

2001-09-05

NAME

        basic_lock - basic lock functions

INHERITS

	/std/stationary

FUNCTIONS

SETUP FUNCTIONS

	set_lock
	set_opened
	set_unlocked

QUERY FUNCTIONS

	query_opened
	query_unlocked
	query_code
	query_type

OTHER FUNCTIONS

	remote_prevent_command
	remote_prevent_open
	remote_prevent_unlock
	remote_do_open
	remote_do_unlock
	replace_vars

PROPERTIES

INTERNAL PROPERTIES


PROPERTY NAME

        open_mess - The message of opening.

DESCRIPTION

	The message that is written when the object opens or closes.

PROPERTY NAME

        unlock_mess - The message when unlocking.

DESCRIPTION

	The message that is written when the object becomes unlocked
	or locked.

PROPERTY NAME

        lock_desc - What does the lock look like?

DESCRIPTION

	The description of the lock. It is normally set by the
	set_lock() function.

PROPERTY NAME

        pick_level - How hard is the lock to pick?

DESCRIPTION

	If another object returns a code that is an integer it is
	compared to the pick_level, and if the code is greater than
	the pick_level the object becomes unlocked. An object without
	this property cannot be picked. 

	Use a pick_level of 1-100; everybody else does.

PROPERTY NAME

        unlocker - Who unlocked the lock?

DESCRIPTION

	This property contains the name of the unlocker object if it
	isn't a key.

PROPERTY NAME

        won't_close - Won't close automatically at reset.

DESCRIPTION

	If this property is set, the object won't close automatically
	at reset.

PROPERTY NAME

        won't_lock - Won't lock automatically at reset.

DESCRIPTION

	If this property is set, the object won't lock itself
	automatically at reset.

PROPERTY NAME

        not_lock_when_open - Won't lock when open.

DESCRIPTION

	It is not possible to lock this object when it's open.

PROPERTY NAME

        code - The code for the lock.

DESCRIPTION

	This gives another object a code for unlocking.
	This is not a property in the basic_lock object. 

DESCRIPTION

	This file contains basic functions and commands for
	opening/closing and locking/unlocking objects.

FUNCTION


NAME

        set_lock - Set the lock code of the object

SYNTAX

	void set_lock(string code [, string type [, string desc]])

DESCRIPTION

	This function sets the lock code for the object and also locks
	the object. It can then be unlocked with a key (or any object)
	that has a function query_code() or a property "code" that
	returns the same code. The code is a simple string that acts
	like a password to the object. The code string will be run
	through eval() everytime it is used.
	The optional argument 'type' sets the type of the lock, which
	is seen in the long description of the object. This usually
	corresponds to the type of key needed to unlock. The optional
	'desc' argument is a description of the lock.

	How to make a simple key? Look at /examples/doors1.c in function
	make_key(). A key is a /std/basic_thing with the alias "key" and
	the property "code".

EXAMPLE

	set_lock("xyzzy");

EXAMPLE

	set_lock("foobar","bronze","The lock is made of bronze.\n");

FUNCTION


NAME

        set_opened - Open/close the object

SYNTAX

	void set_opened(int n)

DESCRIPTION

	If n is 0 it sets the status of the object to closed and
	if n is 1 opens the object.

FUNCTION


NAME

        set_unlocked - Unlocks/lock the object.

SYNTAX

	void set_unlocked(int n)

DESCRIPTION

	If n is 0 it sets the status of the object to locked and
	if n is 1 unlocks the object.

FUNCTION


NAME

        query_opened - Returns open/closed status.

SYNTAX

	int query_opened()

DESCRIPTION

	Returns the open/closed status of the object, 0 for closed and
	1 for opened.

FUNCTION


NAME

        query_unlocked - Returns unlocked/locked status

SYNTAX

	int query_unlocked()

DESCRIPTION

	Returns the unlocked/locked status of the object, 0 for locked
	and 1 for unlocked.

FUNCTION


NAME

        query_code - Returns lock code

SYNTAX

	string query_code()

DESCRIPTION

	Returns the code of the lock. The code string will be run
	through eval() first.

FUNCTION


NAME

        query_type - Returns the type of the object.

SYNTAX

	string query_type()

DESCRIPTION

	Returns the type of the object. It is normally the name set
	with set_name, but can give other results with inherited objects,
	like doors which gives the type "door" if no name is set. This
	is mainly an internal function.

FUNCTION


NAME

        remote_prevent_command - Do extra checks before open/close/unlock/lock.

SYNTAX

	int remote_prevent_command(object obj)

DESCRIPTION

	This function is called when someone tries to do anything with
	the object. If 1 is returned the command doesn't work.

EXAMPLE

	remote_prevent_command(object obj)
	{
	  if (present("guard",environment(obj))
	  {
	    write("Guard says: Hey! Don't touch that door.\n");
	    return 1;
          }
        }

FUNCTION


NAME

        remote_prevent_open - Do extra checks before opening/closing.

SYNTAX

	int remote_prevent_open(object obj)

DESCRIPTION

	This function is called when someone tries to open the object.
	If 1 is returned the object doesn't open.

EXAMPLE

	remote_prevent_open()
	{
	  if (this_player()->query_str() <15)
	  {
	    write("You are too weak to open this heavy door.\n");
	    return 1;
          }
        }

FUNCTION


NAME

        remote_prevent_unlock - Do extra checks before unlocking/locking.

SYNTAX

	int remote_prevent_unlock(object obj, object key)

DESCRIPTION

	This function is called when someone tries to unlock the object.
	If 1 is returned the object doesn't unlock.

FUNCTION


NAME

        remote_do_open - Do extra effects on open/close.

SYNTAX

	int remote_do_open(object obj)

DESCRIPTION

	This function is called when someone opens or closes the object.
	Use query_verb() to check if it was "open" or "close" command.

FUNCTION


NAME

        remote_do_unlock - Do extra effects on unlock/lock.

SYNTAX

	int remote_do_unlock(object obj, object key)

DESCRIPTION

	This function is called when someone unlocks the object

EXAMPLE

	remote_do_unlock(object o, object key)
	{
	  write("The "+key->query_name()+" disappears.\n");
	  destruct(key);
	}

FUNCTION


NAME

        replace_vars - Replace special variables in a string.

SYNTAX

	varargs string replace_vars(mixed mess, string extra)

DESCRIPTION

	This internal function replaces all occurences of certain
	strings with data about the object. The strings are replaced
	like this:
	  $V  -  the verb that was used to do this action, query_verb()
	  $S  -  the opened status of the object, "open" or "closed"
	  $N  -  the name of the object, query_name()
	  $T  -  the type of the object, query_type()
	  $X  -  the "extra" string that is sent to this function

EXAMPLE

	The string "You $V the $S $N" can be replaced to "You open the
	closed small door".