[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /std/basic/close_lock.c</h2>
This class keeps track of whether things are open or closed,
locked or unlocked.  Trap functions that are triggered when
an object is opened or unlocked are also handled.  When
you need an object that is locked you should remember to
use set_key() and set_difficulty().  When cloning an object
and moving other objects inside it you should remember to
make sure the object is open before moving things into it,
and then close it if neccessary.
<p>Written by Gototh
<h2>Includes</h2>
This class includes the following files <a href="include.tasks.h.shtml">/include/tasks.h</a>, <a href="include.move_failures.h.shtml">/include/move_failures.h</a> and <a href="include.clothing.h.shtml">/include/clothing.h</a><h2>Method index</h2>
<dl><ul>
<li><a href="#add_close_lock_commands">add_close_lock_commands</a>(object)<br/>
This method adds the lock commands to the specified player.
<li><a href="#pick_unlock">pick_unlock</a>(object)<br/>
This is called when someone successfully unlocks the object.
<li><a href="#query_autolock">query_autolock</a>()<br/>
This tells us whether an object will lock automatically when closed.
<li><a href="#query_closed">query_closed</a>()<br/>
This function tells you whether an object is open or closed.
<li><a href="#query_closed_locked_status">query_closed_locked_status</a>()<br/>
This method returns the closed and locked status.
<li><a href="#query_difficulty">query_difficulty</a>()<br/>
This returns the difficulty picking the lock on the object.
<li><a href="#query_key">query_key</a>()<br/>
This returns the property of the key that will unlock the
object.
<li><a href="#query_lock_trap_func">query_lock_trap_func</a>()<br/>
This returns the name of the function to be called when
some attempts to unlock the object.
<li><a href="#query_lock_trap_ob">query_lock_trap_ob</a>()<br/>
This returns the object on which the trap function is stored.
<li><a href="#query_locked">query_locked</a>()<br/>
This tells us whether an object is locked.
<li><a href="#query_open">query_open</a>()<br/>
This function tells you whether an object is open or closed.
<li><a href="#query_open_trap_func">query_open_trap_func</a>()<br/>
This returns the name of the function to be called when
someone tries to open the object.
<li><a href="#query_open_trap_ob">query_open_trap_ob</a>()<br/>
This returns the object on which the trap function is stored.
<li><a href="#query_pick_skill">query_pick_skill</a>()<br/>
This returns the name of the skill which is used when
determining if the object can be unlocked.
<li><a href="#query_stuck">query_stuck</a>()<br/>
This tells you whether an object is stuck or not.
<li><a href="#query_transparent">query_transparent</a>()<br/>
This method returns the current transparent
value of the object.
<li><a href="#query_unlocked">query_unlocked</a>()<br/>
This tells us whether an object is unlocked.
<li><a href="#reset_transparent">reset_transparent</a>()<br/>
This method removes the current objects transparent
status.
<li><a href="#set_autolock">set_autolock</a>(int)<br/>
This sets the object so that it will lock automatically when closed.
<li><a href="#set_closed">set_closed</a>(int)<br/>
This sets the object as being closed.
<li><a href="#set_difficulty">set_difficulty</a>(int)<br/>
This sets how difficult the lock on an object is to pick.
<li><a href="#set_key">set_key</a>(mixed)<br/>
This sets the property of the key that will unlock the object.
<li><a href="#set_lock_trap">set_lock_trap</a>(object, string)<br/>
This sets the function to be called when someone attempts to
unlock the object.
<li><a href="#set_locked">set_locked</a>()<br/>
This sets the object as being locked.
<li><a href="#set_open">set_open</a>(int)<br/>
This sets the object as being open.
<li><a href="#set_open_trap">set_open_trap</a>(object, string)<br/>
This sets the function to be called when someone attempts to
open the object.
<li><a href="#set_pick_skill">set_pick_skill</a>(string)<br/>
This sets the skill that will be used when attempting to
pick the lock.
<li><a href="#set_stuck">set_stuck</a>(int)<br/>
This can set an object as being stuck, or make it unstuck.
<li><a href="#set_transparent">set_transparent</a>()<br/>
This sets the object as being transparent.
<li><a href="#set_unlocked">set_unlocked</a>()<br/>
This sets the object as being unlocked.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="add_close_lock_commands">
add_close_lock_commands</a><pre>
void add_close_lock_commands(object player)
</pre></br>
This method adds the lock commands to the specified player.
It's been abstracted out of init() to make it easier for some
odd situations (like the t-shop).


<ul><a name="pick_unlock">
pick_unlock</a><pre>
int pick_unlock(object player)
</pre></br>
This is called when someone successfully unlocks the object.
If there is a trap, and the trap function returns true, the
object will not be opened.  If the trap function returns
false, the object will still be opened even if the trap is
sprung.

<br/><ul>
<li><b>Parameters:</b>
<br/>player - The player who is unlocking the object.

<li><b>Returns:</b>
<br/>Returns 1 if the object was unlocked, and 0 otherwise.

</dl>

<ul><a name="query_autolock">
query_autolock</a><pre>
int query_autolock()
</pre></br>
This tells us whether an object will lock automatically when closed.

<br/><ul>
<li><b>Returns:</b>
<br/>1 for true 0 for false;

<li><b>See also:</b>
<br/><a href="#set_autolock">set_autolock()</a></dl>

<ul><a name="query_closed">
query_closed</a><pre>
int query_closed()
</pre></br>
This function tells you whether an object is open or closed.
It returns 1 if the object is closed, and 0 if the object is open.

<br/><ul>
<li><b>Returns:</b>
<br/>Return 1 if closed, 0 if open.
<li><b>See also:</b>
<br/><a href="#set_open">set_open()</a> and <a href="#set_closed">set_closed()
</a></dl>

<ul><a name="query_closed_locked_status">
query_closed_locked_status</a><pre>
int query_closed_locked_status()
</pre></br>
This method returns the closed and locked status.  The status is
0 if open and unlocked, 1 if locked, 2 if closed and 3 if closed
and locked.
<br/><ul>
<li><b>Returns:</b>
<br/>closed and locked status

</dl>

<ul><a name="query_difficulty">
query_difficulty</a><pre>
int query_difficulty()
</pre></br>
This returns the difficulty picking the lock on the object.
By default it is set to 200 unless it has been changed with
set_difficulty().

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_difficulty">set_difficulty()
</a></dl>

<ul><a name="query_key">
query_key</a><pre>
string query_key()
</pre></br>
This returns the property of the key that will unlock the
object.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_key">set_key()
</a></dl>

<ul><a name="query_lock_trap_func">
query_lock_trap_func</a><pre>
string query_lock_trap_func()
</pre></br>
This returns the name of the function to be called when
some attempts to unlock the object.

<br/><ul>
<li><b>Returns:</b>
<br/>The function to be called when someone attempts
to unlock the object.
<li><b>See also:</b>
<br/><a href="#set_open_trap">set_open_trap()</a> and <a href="#query_open_trap_ob">query_open_trap_ob()
</a></dl>

<ul><a name="query_lock_trap_ob">
query_lock_trap_ob</a><pre>
object query_lock_trap_ob()
</pre></br>
This returns the object on which the trap function is stored.
The trap function is called when someone tries to unlock the
the object.

<br/><ul>
<li><b>Returns:</b>
<br/>The function to be called when the object is opened.
<li><b>See also:</b>
<br/><a href="#set_open_trap">set_open_trap()</a> and <a href="#query_open_trap_func">query_open_trap_func()
</a></dl>

<ul><a name="query_locked">
query_locked</a><pre>
int query_locked()
</pre></br>
This tells us whether an object is locked.  It returns 1 if
the object is locked and 0 is the object is unlocked.

<br/><ul>
<li><b>Returns:</b>
<br/>Return 1 if locked and 0 if unlocked.

<li><b>See also:</b>
<br/><a href="#set_locked">set_locked()</a> and <a href="#set_unlocked">set_unlocked()</a></dl>

<ul><a name="query_open">
query_open</a><pre>
int query_open()
</pre></br>
This function tells you whether an object is open or closed.
It returns 1 if the object is open and 0 if the object is closed.

<br/><ul>
<li><b>Returns:</b>
<br/>Return 1 if open, 0 if closed.
<li><b>See also:</b>
<br/><a href="#set_open">set_open()</a> and <a href="#set_closed">set_closed()
</a></dl>

<ul><a name="query_open_trap_func">
query_open_trap_func</a><pre>
string query_open_trap_func()
</pre></br>
This returns the name of the function to be called when
someone tries to open the object.

<br/><ul>
<li><b>Returns:</b>
<br/>The function to be called when the object is opened.
<li><b>See also:</b>
<br/><a href="#set_open_trap">set_open_trap()</a> and <a href="#query_open_trap_ob">query_open_trap_ob()
</a></dl>

<ul><a name="query_open_trap_ob">
query_open_trap_ob</a><pre>
object query_open_trap_ob()
</pre></br>
This returns the object on which the trap function is stored.
The trap function is called when someone tries to open the
the object.

<br/><ul>
<li><b>Returns:</b>
<br/>The function to be called when the object is opened.
<li><b>See also:</b>
<br/><a href="#set_open_trap">set_open_trap()</a> and <a href="#query_open_trap_func">query_open_trap_func()
</a></dl>

<ul><a name="query_pick_skill">
query_pick_skill</a><pre>
string query_pick_skill()
</pre></br>
This returns the name of the skill which is used when
determining if the object can be unlocked.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_pick_skill">set_pick_skill()
</a></dl>

<ul><a name="query_stuck">
query_stuck</a><pre>
int query_stuck()
</pre></br>
This tells you whether an object is stuck or not.  It will
return 1 if the object is stuck, and 0 if the object is not
stuck.

<br/><ul>
<li><b>Returns:</b>
<br/>Return 1 if the object is stuck, and 0 if it is not.

<li><b>See also:</b>
<br/><a href="#set_stuck">set_stuck()</a></dl>

<ul><a name="query_transparent">
query_transparent</a><pre>
int query_transparent()
</pre></br>
This method returns the current transparent
value of the object.
A transparent object is one in which you can see the
inventory even if it is closed.  This is also
used for light propogration.

<br/><ul>
<li><b>Returns:</b>
<br/>1 if the object is transparent

<li><b>See also:</b>
<br/><a href="#reset_transparent">reset_transparent()</a> and <a href="#query_transparent">query_transparent()</a></dl>

<ul><a name="query_unlocked">
query_unlocked</a><pre>
int query_unlocked()
</pre></br>
This tells us whether an object is unlocked.  It returns 1 if
the object is unlocked and 0 is the object is locked.

<br/><ul>
<li><b>Returns:</b>
<br/>Return 1 if unlocked and 0 if locked.

<li><b>See also:</b>
<br/><a href="#set_locked">set_locked()</a> and <a href="#set_unlocked">set_unlocked()</a></dl>

<ul><a name="reset_transparent">
reset_transparent</a><pre>
void reset_transparent()
</pre></br>
This method removes the current objects transparent
status.
A transparent object is one in which you can see the
inventory even if it is closed.  This is also
used for light propogration.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_transparent">set_transparent()</a> and <a href="#query_transparent">query_transparent()
</a></dl>

<ul><a name="set_autolock">
set_autolock</a><pre>
void set_autolock(int number)
</pre></br>
This sets the object so that it will lock automatically when closed.

<br/><ul>
<li><b>Parameters:</b>
<br/>number - 1 for autolock, 0 for no autolock.

</dl>

<ul><a name="set_closed">
set_closed</a><pre>
varargs void set_closed(int no_event)
</pre></br>
This sets the object as being closed.  If you are moving
objects into the object, make sure that you do not set
the object as closed and then try to move the objects in.
Move the objects in and then close the object.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_open">set_open()</a> and <a href="#query_closed">query_closed()
</a></dl>

<ul><a name="set_difficulty">
set_difficulty</a><pre>
void set_difficulty(int i)
</pre></br>
This sets how difficult the lock on an object is to pick.
By default it is set to 200.

<br/><ul>
<li><b>Parameters:</b>
<br/>i - The difficulty of the lock to pick.

<li><b>See also:</b>
<br/><a href="#query_difficulty">query_difficulty()</a></dl>

<ul><a name="set_key">
set_key</a><pre>
void set_key(mixed val)
</pre></br>
This sets the property of the key that will unlock the object. This can
be a string, or a function pointer which will evaluate to a string.

<br/><ul>
<li><b>Parameters:</b>
<br/>val - The property the key must have to unlock the object.

<li><b>See also:</b>
<br/><a href="#set_locked">set_locked()</a></dl>

<ul><a name="set_lock_trap">
set_lock_trap</a><pre>
void set_lock_trap(object ob,
                   string func)
</pre></br>
This sets the function to be called when someone attempts to
unlock the object.  The function does not have to be in the
object's file, and can be specified using the 'ob' paramater.
In most cases the function will be stored in the same file,
so use this_object() in these cases.

The function will be called with a single string parameter of "lock",
"unlock" or "pick"

<br/><ul>
<li><b>Parameters:</b>
<br/>ob - The object in which the function is stored.
<br/>func - The function to be called.
<li><b>See also:</b>
<br/><a href="#query_lock_trap_func">query_lock_trap_func()</a> and <a href="#query_lock_trap_ob">query_lock_trap_ob()
</a></dl>

<ul><a name="set_locked">
set_locked</a><pre>
void set_locked()
</pre></br>
This sets the object as being locked.  Remember to set the
object as being closed before using this.  In most cases you
should probably use set_key() to set the key which opens the
lock and use set_difficulty() to set the skill level required
to pick the lock.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_open">set_open()</a>, <a href="#set_closed">set_closed()</a>, <a href="#set_key">set_key()</a> and <a href="#set_difficulty">set_difficulty()
</a></dl>

<ul><a name="set_open">
set_open</a><pre>
varargs void set_open(int no_event)
</pre></br>
This sets the object as being open.  Note that to find out
if an object is open we use query_closed() which will return
0 if the object is open.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_closed">set_closed()</a> and <a href="#query_closed">query_closed()
</a></dl>

<ul><a name="set_open_trap">
set_open_trap</a><pre>
void set_open_trap(object ob,
                   string func)
</pre></br>
This sets the function to be called when someone attempts to
open the object.  The function does not have to be in the
object's file, and can be specified using the 'ob' paramater.
In most cases the function will be stored in the same file,
so use this_object() in these cases.

The function will be called with a single string parameter of "open" or
"close"

<br/><ul>
<li><b>Parameters:</b>
<br/>ob - The object in which the function is stored.
<br/>func - The function to be called.
<li><b>See also:</b>
<br/><a href="#query_open_trap_func">query_open_trap_func()</a> and <a href="#query_open_trap_ob">query_open_trap_ob()
</a></dl>

<ul><a name="set_pick_skill">
set_pick_skill</a><pre>
void set_pick_skill(string str)
</pre></br>
This sets the skill that will be used when attempting to
pick the lock.  By default it is set to "covert.lockpick.safes"
so it need only be changed if you want to check a different
skill.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - The skill to use when picking the lock.

<li><b>See also:</b>
<br/><a href="#query_pick_skill">query_pick_skill()</a> and <a href="#set_difficulty">set_difficulty()</a></dl>

<ul><a name="set_stuck">
set_stuck</a><pre>
void set_stuck(int i)
</pre></br>
This can set an object as being stuck, or make it unstuck.
Stuck objects cannot be opened, closed, locked or unlocked.
Using set_stuck(1) will make the object stuck, and set_stuck(0)
will unstick it.

<br/><ul>
<li><b>Parameters:</b>
<br/>i - Use 1 to make the object stuck, and 0 to unstick it.

<li><b>See also:</b>
<br/><a href="#query_stuck">query_stuck()</a></dl>

<ul><a name="set_transparent">
set_transparent</a><pre>
void set_transparent()
</pre></br>
This sets the object as being transparent.
A transparent object is one in which you can see the
inventory even if it is closed.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#reset_transparent">reset_transparent()</a> and <a href="#query_transparent">query_transparent()
</a></dl>

<ul><a name="set_unlocked">
set_unlocked</a><pre>
void set_unlocked()
</pre></br>
This sets the object as being unlocked.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_locked">set_locked()
</a></dl>


[an error occurred while processing this directive]

