[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 /global/psoul.c</h2>
This class controls the entire command queue for all player
objects.  Whenever a player tries to execute a command,
it gets placed in a queue here and eventually (during the
player's heart_beat()), the command will (hopefully) be executed.

<p>Since this class is a nexus of control for player commands, it
is also the natural place for a number of other utilities and
functions which also affect the execution of all commands.
Among these are things like drunk_check(), do_soul(), etc.
<p><b>See also:</b><br><a href="global.new_parse.c.shtml#add_command">/global/new_parse->add_command()</a>, <a href="global.player.c.shtml#heart_beat">/global/player->heart_beat()</a> and <a href="#query_passed_out_message">query_passed_out_message()
</a><p>Written by Pinkfish<h3>Change history</h3>
<ul><li>3 November 1997 -- Sin<br/>     Documented the bejeesus out of this thing.
<li>4 Novemebr 1997 - Pinkfish<br/>     Updated the documentation and changed the interupt system slightly.
<li>22 Feburary 1998 - Pinkfish<br/>     Fixed up the problems with the queueing system.
</ul>
<h2>Inherits</h2>
This class inherits the following classes <a href="global.alias.c.shtml">/global/alias.c</a> and <a href="global.nickname.c.shtml">/global/nickname.c</a><h2>Includes</h2>
This class includes the following files <a href="include.playtesters.h.shtml">/include/playtesters.h</a>, <a href="include.soul.h.shtml">/include/soul.h</a>, <a href="include.living.h.shtml">/include/living.h</a> and <a href="include.player.h.shtml">/include/player.h</a><h2>Method index</h2>
<dl><ul>
<li><a href="#adjust_time_left">adjust_time_left</a>(int)<br/>
Change the amount of time a player has left.
<li><a href="#bypass_queue">bypass_queue</a>()<br/>
To make the next single command be executed directly rather
than being placed in the command queue, call this function.
<li><a href="#command_override">command_override</a>(function)<br/>
Use this function to set a function that is called with the players input
before the command handlers get to it, return 1 from the function if the
input needs no further parsing (ie the command is handled)

<li><a href="#do_soul">do_soul</a>(string, mixed)<br/>
All soul commands eventually call this function to output their
messages.
<li><a href="#drunk_check">drunk_check</a>(string)<br/>
This poorly named function was originally used to affect the
player's behavior when they are drunk, and to prevent any
player from doing anything in the event that they are passed
out.
<li><a href="#flush_queue">flush_queue</a>()<br/>
This method flushes all the queued commands.
<li><a href="#interupt_command">interupt_command</a>(object)<br/>
This method interupts the current command.
<li><a href="#lower_check">lower_check</a>(string)<br/>
This function will get called when all other commands and actions
have refused to do anything for this input from the user.
<li><a href="#no_time_left">no_time_left</a>()<br/>
Ensure that the player has no more time for executing commands.
<li><a href="#process_input">process_input</a>(string)<br/>
This is the command called by the driver on a player object every
time a command is executed.
<li><a href="#query_interupt_command">query_interupt_command</a>()<br/>
This method returns the current value associated with tine interupt
command.
<li><a href="#query_queued_commands">query_queued_commands</a>()<br/>
You can use this function to see if there are any commands
queued for this player.
<li><a href="#query_time_left">query_time_left</a>()<br/>
The amount of time units left.
<li><a href="#remove_queue">remove_queue</a>()<br/>
This is called by the stop command.
<li><a href="#set_interrupt_command">set_interrupt_command</a>(function)<br/>
Fixes a spelling error.
<li><a href="#set_interupt_command">set_interupt_command</a>(mixed, mixed, mixed)<br/>
Sets the function to be executed if the command is interrupted.
<li><a href="#soul_com_force">soul_com_force</a>(string)<br/>
Some of the soul commands force the target to do something.
<li><a href="#soul_commands">soul_commands</a>()<br/>
This is a setup function that is called by the player object.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="adjust_time_left">
adjust_time_left</a><pre>
int adjust_time_left(int i)
</pre></br>
Change the amount of time a player has left.  You call this after a command
has been executed to make it take more time.
<br/><ul>
<li><b>Parameters:</b>
<br/>i - the amount of time units to change by
<li><b>Returns:</b>
<br/>the amount of time left

</dl>

<ul><a name="bypass_queue">
bypass_queue</a><pre>
void bypass_queue()
</pre></br>
To make the next single command be executed directly rather
than being placed in the command queue, call this function.


<ul><a name="command_override">
command_override</a><pre>
void command_override(function func)
</pre></br>
Use this function to set a function that is called with the players input
before the command handlers get to it, return 1 from the function if the
input needs no further parsing (ie the command is handled)

<br/><ul>
<li><b>Parameters:</b>
<br/>func - = function in the players environment to call.

</dl>

<ul><a name="do_soul">
do_soul</a><pre>
void do_soul(string str,
             mixed bing)
</pre></br>
All soul commands eventually call this function to output their
messages.  This is nothing more than a wrapper for say(), but
it provides a convenient name by which a shadow on the
player object can replace any soul behavior.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - the string being printed
</dl>

<ul><a name="interupt_command">
interupt_command</a><pre>
void interupt_command(object interupter)
</pre></br>
This method interupts the current command.
<br/><ul>
<li><b>Parameters:</b>
<br/>interupter - the person interupting the command

</dl>

<ul><a name="lower_check">
lower_check</a><pre>
int lower_check(string str)
</pre></br>
This function will get called when all other commands and actions
have refused to do anything for this input from the user.  This
function adds some extra time for the user, and then returns.

<p>This function is registered via add_action() with a 
priority of -10000.  If you want to bypass it, then use a priority
higher than that.  If you want to see what strings get dropped by the
entire add_action() stack, then use a priority lower.

<br/><ul>
<li><b>Returns:</b>
<br/>1 if the user's input is "stop", otherwise 0.

</dl>

<ul><a name="no_time_left">
no_time_left</a><pre>
void no_time_left()
</pre></br>
Ensure that the player has no more time for executing commands.
This will force the next command to be queued.


<ul><a name="query_interupt_command">
query_interupt_command</a><pre>
mixed * query_interupt_command()
</pre></br>
This method returns the current value associated with tine interupt
command.
<br/><ul>
<li><b>Returns:</b>
<br/>the current interupt command data

</dl>

<ul><a name="query_queued_commands">
query_queued_commands</a><pre>
int query_queued_commands()
</pre></br>
You can use this function to see if there are any commands
queued for this player.
<br/><ul>
<li><b>Returns:</b>
<br/>the number of queued commands

</dl>

<ul><a name="query_time_left">
query_time_left</a><pre>
int query_time_left()
</pre></br>
The amount of time units left.  A time unit is 1/40th of a second.


<ul><a name="remove_queue">
remove_queue</a><pre>
void remove_queue()
</pre></br>
This is called by the stop command.  It sets the entire queue back to
empty.  It calls the interrupt functions and stuff if they need to be
called.


<ul><a name="set_interrupt_command">
set_interrupt_command</a><pre>
void set_interrupt_command(function func)
</pre></br>
Fixes a spelling error.   This one only takes a function pointer as an
input.

<br/><ul>
<li><b>Parameters:</b>
<br/>func - the function pointer to call back with

</dl>

<ul><a name="set_interupt_command">
set_interupt_command</a><pre>
void set_interupt_command(mixed func,
                          mixed ob,
                          mixed arg)
</pre></br>
Sets the function to be executed if the command is interrupted.
It is also executed if teh command finished.  If it is interrupted
the first arguement to the called function will be the amount of time
it had left to complete.  If it complets successfuly, this
argument will be 0.  If the first argument is a function pointer,
this will be used instead.<p>

Eg: set_interupt_command("frog", this_object());<p>
void frog(int time_left, mixed arg) { <p>
... <p>
}

<br/><ul>
<li><b>Parameters:</b>
<br/>func - the function to call back
<br/>ob - the object to call the function on
<br/>arg - the argument to pass to the function
<li><b>Example:</b>
<br/><pre>...
void frog(int time_left, mixed arg);
...
set_interupt_commant((: frog :));
...
void frog(int time_left, mixed arg) {
   ...
} /* frog() */
</pre></dl>

<ul><a name="soul_com_force">
soul_com_force</a><pre>
int soul_com_force(string str)
</pre></br>
Some of the soul commands force the target to do something.
An example is the 'tickle' soul, which forces the target to
'giggle'.  Those soul-forces call this function.  But only
the soul object can use this function: any other object which calls
this function will be ignored.  This prevents this function
from being used to bypass the security checking on the
'force' command.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - the command being forced
<li><b>Returns:</b>
<br/>0 if the command was ignored, otherwise 1.

</dl>

<ul><a name="soul_commands">
soul_commands</a><pre>
void soul_commands()
</pre></br>
This is a setup function that is called by the player object.
It is used to register the lower_check() and drunk_check()
functions.  Plus it initializes the alias object, the
nickname object, and the history object.



<h2>Protected Functions</h2>
These are functions that only objects inheriting the class can access.<p>
<ul><a name="drunk_check">
drunk_check</a><pre>
int drunk_check(string str)
</pre></br>
This poorly named function was originally used to affect the
player's behavior when they are drunk, and to prevent any
player from doing anything in the event that they are passed
out.  Now the function also is responsible for adding commands
to the player's command queue, for implementing the 'stop'
and 'restart' commands, and for ensuring that the player can quit
the game, even when queueing.

<p>To see if a player is passed out, it checks the
"passed out" property.  If that property is nonzero, then
the player will be prevented from doing the command unless
that player is also a creator.  By default, it will print
a message that says: "You are unconscious.  You can't do
anything.\n".  If the function query_passed_out_message() is
defined on the player object (usually by a shadow), and
returns a string, then that string is printed instead.

<p>This function is registered with
add_action("drunk_check", "*", 10000),
so it can be avoided by registering a higher priority add_action.
But that is not necessary, because if bypass_queue() has
been called, this function will do nothing.  Please note that
you should not be using add_action.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - the command being executed

<li><b>Returns:</b>
<br/>0 if nothing was done, 1 if drunk_check() blocked
the command.
<li><b>See also:</b>
<br/><a href="global.new_parse.c.shtml#add_command">/global/new_parse->add_command()
</a></dl>

<ul><a name="flush_queue">
flush_queue</a><pre>
void flush_queue()
</pre></br>
This method flushes all the queued commands.  It increments the time by the
ROUND_TIME define and checks to see if any of the commands now need to be
executed.  This should be called each heart beat..

<br/><ul>
<li><b>See also:</b>
<br/><a href="global.player.c.shtml#heart_beat">/global/player->heart_beat()
</a></dl>

<ul><a name="process_input">
process_input</a><pre>
string process_input(string str)
</pre></br>
This is the command called by the driver on a player object every
time a command is executed.  It expands the history comands.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - the string to expand
<li><b>Returns:</b>
<br/>the expanded history string

</dl>


[an error occurred while processing this directive]

