skylib_fluffos_v3/
skylib_fluffos_v3/bin/
skylib_fluffos_v3/bin/db/
skylib_fluffos_v3/fluffos-2.9-ds2.04/
skylib_fluffos_v3/fluffos-2.9-ds2.04/ChangeLog.old/
skylib_fluffos_v3/fluffos-2.9-ds2.04/Win32/
skylib_fluffos_v3/fluffos-2.9-ds2.04/compat/
skylib_fluffos_v3/fluffos-2.9-ds2.04/compat/simuls/
skylib_fluffos_v3/fluffos-2.9-ds2.04/include/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/clone/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/command/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/data/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/etc/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/include/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/inherit/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/inherit/master/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/log/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/compiler/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/efuns/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/operators/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/u/
skylib_fluffos_v3/fluffos-2.9-ds2.04/tmp/
skylib_fluffos_v3/fluffos-2.9-ds2.04/windows/
skylib_fluffos_v3/mudlib/
skylib_fluffos_v3/mudlib/cmds/
skylib_fluffos_v3/mudlib/cmds/admin/
skylib_fluffos_v3/mudlib/cmds/guild-race/
skylib_fluffos_v3/mudlib/cmds/living/broken/
skylib_fluffos_v3/mudlib/cmds/player/group_cmds/
skylib_fluffos_v3/mudlib/cmds/playtester/
skylib_fluffos_v3/mudlib/d/admin/
skylib_fluffos_v3/mudlib/d/admin/room/
skylib_fluffos_v3/mudlib/d/admin/room/we_care/
skylib_fluffos_v3/mudlib/d/admin/save/
skylib_fluffos_v3/mudlib/d/admin/text/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/buildings/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/map/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/roads/
skylib_fluffos_v3/mudlib/d/learning/chars/
skylib_fluffos_v3/mudlib/d/learning/functions/
skylib_fluffos_v3/mudlib/d/learning/handlers/
skylib_fluffos_v3/mudlib/d/learning/help_topics/
skylib_fluffos_v3/mudlib/d/learning/help_topics/npcs/
skylib_fluffos_v3/mudlib/d/learning/help_topics/objects/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rcs_demo/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rcs_demo/RCS/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/crowd/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/situations/
skylib_fluffos_v3/mudlib/d/learning/save/
skylib_fluffos_v3/mudlib/d/learning/school/
skylib_fluffos_v3/mudlib/d/learning/school/add_sc/
skylib_fluffos_v3/mudlib/d/learning/school/characters/
skylib_fluffos_v3/mudlib/d/learning/school/general/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/basic_commands/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/edtutor/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/unix_tutor/
skylib_fluffos_v3/mudlib/d/learning/school/items/
skylib_fluffos_v3/mudlib/d/learning/school/npc_school/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/room_basic/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/situations/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/terrain_tutor/
skylib_fluffos_v3/mudlib/d/learning/text/
skylib_fluffos_v3/mudlib/d/liaison/
skylib_fluffos_v3/mudlib/d/mudlib/
skylib_fluffos_v3/mudlib/d/mudlib/changes/
skylib_fluffos_v3/mudlib/d/playtesters/
skylib_fluffos_v3/mudlib/d/playtesters/effects/
skylib_fluffos_v3/mudlib/d/playtesters/handlers/
skylib_fluffos_v3/mudlib/d/playtesters/items/
skylib_fluffos_v3/mudlib/d/sage/
skylib_fluffos_v3/mudlib/doc/
skylib_fluffos_v3/mudlib/doc/creator/
skylib_fluffos_v3/mudlib/doc/driver/
skylib_fluffos_v3/mudlib/doc/driver/efuns/arrays/
skylib_fluffos_v3/mudlib/doc/driver/efuns/buffers/
skylib_fluffos_v3/mudlib/doc/driver/efuns/calls/
skylib_fluffos_v3/mudlib/doc/driver/efuns/compile/
skylib_fluffos_v3/mudlib/doc/driver/efuns/filesystem/
skylib_fluffos_v3/mudlib/doc/driver/efuns/floats/
skylib_fluffos_v3/mudlib/doc/driver/efuns/functions/
skylib_fluffos_v3/mudlib/doc/driver/efuns/general/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mappings/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mixed/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mudlib/
skylib_fluffos_v3/mudlib/doc/driver/efuns/numbers/
skylib_fluffos_v3/mudlib/doc/driver/efuns/parsing/
skylib_fluffos_v3/mudlib/doc/login/
skylib_fluffos_v3/mudlib/doc/lpc/basic_manual/
skylib_fluffos_v3/mudlib/doc/lpc/intermediate/
skylib_fluffos_v3/mudlib/doc/new/add_command/
skylib_fluffos_v3/mudlib/doc/new/events/
skylib_fluffos_v3/mudlib/doc/new/handlers/
skylib_fluffos_v3/mudlib/doc/new/living/race/
skylib_fluffos_v3/mudlib/doc/new/living/spells/
skylib_fluffos_v3/mudlib/doc/new/object/
skylib_fluffos_v3/mudlib/doc/new/player/
skylib_fluffos_v3/mudlib/doc/new/room/guild/
skylib_fluffos_v3/mudlib/doc/new/room/outside/
skylib_fluffos_v3/mudlib/doc/new/room/storeroom/
skylib_fluffos_v3/mudlib/doc/object/
skylib_fluffos_v3/mudlib/doc/playtesters/
skylib_fluffos_v3/mudlib/doc/policy/
skylib_fluffos_v3/mudlib/doc/weapons/
skylib_fluffos_v3/mudlib/global/
skylib_fluffos_v3/mudlib/global/creator/
skylib_fluffos_v3/mudlib/handlers/
skylib_fluffos_v3/mudlib/include/casino/
skylib_fluffos_v3/mudlib/include/cmds/
skylib_fluffos_v3/mudlib/include/effects/
skylib_fluffos_v3/mudlib/include/npc/
skylib_fluffos_v3/mudlib/include/room/
skylib_fluffos_v3/mudlib/include/shops/
skylib_fluffos_v3/mudlib/net/daemon/
skylib_fluffos_v3/mudlib/net/daemon/chars/
skylib_fluffos_v3/mudlib/net/inherit/
skylib_fluffos_v3/mudlib/net/obj/
skylib_fluffos_v3/mudlib/net/obj/BACKUPS/
skylib_fluffos_v3/mudlib/obj/amulets/
skylib_fluffos_v3/mudlib/obj/armours/plate/
skylib_fluffos_v3/mudlib/obj/b_day/
skylib_fluffos_v3/mudlib/obj/clothes/transport/horse/
skylib_fluffos_v3/mudlib/obj/faith/symbols/
skylib_fluffos_v3/mudlib/obj/fungi/
skylib_fluffos_v3/mudlib/obj/gatherables/
skylib_fluffos_v3/mudlib/obj/instruments/
skylib_fluffos_v3/mudlib/obj/media/
skylib_fluffos_v3/mudlib/obj/misc/player_shop/
skylib_fluffos_v3/mudlib/obj/monster/godmother/
skylib_fluffos_v3/mudlib/obj/monster/transport/
skylib_fluffos_v3/mudlib/obj/rings/
skylib_fluffos_v3/mudlib/obj/scabbards/
skylib_fluffos_v3/mudlib/obj/spells/
skylib_fluffos_v3/mudlib/obj/stationery/
skylib_fluffos_v3/mudlib/obj/stationery/envelopes/
skylib_fluffos_v3/mudlib/obj/toys/
skylib_fluffos_v3/mudlib/obj/vessels/
skylib_fluffos_v3/mudlib/obj/weapons/axes/
skylib_fluffos_v3/mudlib/obj/weapons/chains/
skylib_fluffos_v3/mudlib/obj/weapons/maces/BACKUPS/
skylib_fluffos_v3/mudlib/save/autodoc/
skylib_fluffos_v3/mudlib/save/book_handler/
skylib_fluffos_v3/mudlib/save/books/history/calarien/
skylib_fluffos_v3/mudlib/save/mail/
skylib_fluffos_v3/mudlib/save/new_soul/data/
skylib_fluffos_v3/mudlib/save/parcels/
skylib_fluffos_v3/mudlib/save/playerinfo/
skylib_fluffos_v3/mudlib/save/players/d/
skylib_fluffos_v3/mudlib/save/players/s/
skylib_fluffos_v3/mudlib/save/random_names/
skylib_fluffos_v3/mudlib/save/random_names/data/
skylib_fluffos_v3/mudlib/save/terrains/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_desert/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_grassy_field/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_mountain/
skylib_fluffos_v3/mudlib/save/todo_lists/
skylib_fluffos_v3/mudlib/secure/
skylib_fluffos_v3/mudlib/secure/cmds/admin/
skylib_fluffos_v3/mudlib/secure/cmds/lord/
skylib_fluffos_v3/mudlib/secure/config/
skylib_fluffos_v3/mudlib/secure/handlers/autodoc/
skylib_fluffos_v3/mudlib/secure/handlers/intermud/
skylib_fluffos_v3/mudlib/secure/include/global/
skylib_fluffos_v3/mudlib/secure/save/
skylib_fluffos_v3/mudlib/secure/save/handlers/
skylib_fluffos_v3/mudlib/secure/std/
skylib_fluffos_v3/mudlib/secure/std/classes/
skylib_fluffos_v3/mudlib/secure/std/modules/
skylib_fluffos_v3/mudlib/std/creator/
skylib_fluffos_v3/mudlib/std/dom/
skylib_fluffos_v3/mudlib/std/effects/
skylib_fluffos_v3/mudlib/std/effects/external/
skylib_fluffos_v3/mudlib/std/effects/fighting/
skylib_fluffos_v3/mudlib/std/effects/magic/
skylib_fluffos_v3/mudlib/std/effects/magic/BACKUPS/
skylib_fluffos_v3/mudlib/std/effects/other/BACKUPS/
skylib_fluffos_v3/mudlib/std/effects/priest/
skylib_fluffos_v3/mudlib/std/effects/room/
skylib_fluffos_v3/mudlib/std/environ/
skylib_fluffos_v3/mudlib/std/guilds/
skylib_fluffos_v3/mudlib/std/guilds/old/
skylib_fluffos_v3/mudlib/std/languages/
skylib_fluffos_v3/mudlib/std/liquids/
skylib_fluffos_v3/mudlib/std/npc/
skylib_fluffos_v3/mudlib/std/npc/goals/
skylib_fluffos_v3/mudlib/std/npc/goals/basic/
skylib_fluffos_v3/mudlib/std/npc/goals/misc/
skylib_fluffos_v3/mudlib/std/npc/plans/
skylib_fluffos_v3/mudlib/std/npc/plans/basic/
skylib_fluffos_v3/mudlib/std/npc/types/
skylib_fluffos_v3/mudlib/std/npc/types/helper/
skylib_fluffos_v3/mudlib/std/npcs/
skylib_fluffos_v3/mudlib/std/outsides/
skylib_fluffos_v3/mudlib/std/races/shadows/
skylib_fluffos_v3/mudlib/std/room/basic/BACKUPS/
skylib_fluffos_v3/mudlib/std/room/basic/topography/
skylib_fluffos_v3/mudlib/std/room/controller/
skylib_fluffos_v3/mudlib/std/room/inherit/topography/
skylib_fluffos_v3/mudlib/std/room/topography/area/
skylib_fluffos_v3/mudlib/std/room/topography/iroom/
skylib_fluffos_v3/mudlib/std/room/topography/milestone/
skylib_fluffos_v3/mudlib/std/shadows/curses/
skylib_fluffos_v3/mudlib/std/shadows/disease/
skylib_fluffos_v3/mudlib/std/shadows/fighting/
skylib_fluffos_v3/mudlib/std/shadows/healing/
skylib_fluffos_v3/mudlib/std/shadows/magic/
skylib_fluffos_v3/mudlib/std/shadows/poison/
skylib_fluffos_v3/mudlib/std/shadows/room/
skylib_fluffos_v3/mudlib/std/shops/controllers/
skylib_fluffos_v3/mudlib/std/shops/objs/
skylib_fluffos_v3/mudlib/std/shops/player_shop/
skylib_fluffos_v3/mudlib/std/socket/
skylib_fluffos_v3/mudlib/std/soul/d/
skylib_fluffos_v3/mudlib/std/soul/e/
skylib_fluffos_v3/mudlib/std/soul/i/
skylib_fluffos_v3/mudlib/std/soul/j/
skylib_fluffos_v3/mudlib/std/soul/k/
skylib_fluffos_v3/mudlib/std/soul/l/
skylib_fluffos_v3/mudlib/std/soul/n/
skylib_fluffos_v3/mudlib/std/soul/o/
skylib_fluffos_v3/mudlib/std/soul/q/
skylib_fluffos_v3/mudlib/std/soul/r/
skylib_fluffos_v3/mudlib/std/soul/u/
skylib_fluffos_v3/mudlib/std/soul/v/
skylib_fluffos_v3/mudlib/std/soul/y/
skylib_fluffos_v3/mudlib/std/soul/z/
skylib_fluffos_v3/mudlib/std/stationery/
skylib_fluffos_v3/mudlib/w/
skylib_fluffos_v3/mudlib/w/default/
skylib_fluffos_v3/mudlib/w/default/armour/
skylib_fluffos_v3/mudlib/w/default/clothes/
skylib_fluffos_v3/mudlib/w/default/item/
skylib_fluffos_v3/mudlib/w/default/npc/
skylib_fluffos_v3/mudlib/w/default/room/
skylib_fluffos_v3/mudlib/w/default/weapon/
skylib_fluffos_v3/mudlib/www/
skylib_fluffos_v3/mudlib/www/java/
skylib_fluffos_v3/mudlib/www/secure/
skylib_fluffos_v3/mudlib/www/secure/lpc/advanced/
skylib_fluffos_v3/mudlib/www/secure/lpc/intermediate/
skylib_fluffos_v3/win32/
<h3>Chapter 2: About programs</h3>
<p>
The title of this chapter of the textbook is actually poorly named,
since one does not write programs in LPC. An LPC coder instead
writes <B>objects</B>. What is the difference? Well, for our purposes
now, the difference is in the way the file is executed. When you
&quot;run&quot; a program, execution begins at a definite place
in the program. In other words, there is a place in all programs
that is noted as the beginning where program execution starts.
In addition, programs have definite end points, so that when execution
reaches that point, the execution of the program terminates. So,
in short, execution of a program runs from a definite beginning
point through to a definite end point. This is not so with LPC
objects.
</p>
<p>
With muds, LPC objects are simply distinct parts of the C program
which is running the game (the driver). In other words, execution
of the mud program begins and ends in the driver. But the driver
in fact does very little in the way of creating the world you
know when you play a mud. Instead, the driver relies heavily on
the code created in LPC, executing lines of the objects in the
mud as needed. LPC objects thus have no place that is necessarily
the beginning point, nor do they have a definite ending point.
</p>
</p>
Like other programming languages, an LPC &quot;program&quot; may
be made up of one or more files. For an LPC object to get executed,
it simple needs to be loaded into the driver's memory. The driver
will call lines from the object as it needs according to a structure
which will be defined throughout this textbook. The important thing you need
to understand at this point is that there is no &quot;beginning&quot;
to an LPC object in terms of execution, and there is no &quot;end&quot;.
</p>
<hr size="1">
<p><strong>Driver-mudlib interaction</strong></p>
<p>
As I have mentioned earlier, the driver is the C program that
runs on the host machine. It connects you into the game and processes
LPC code. Note that this is one theory of mud programming, and
not necessarily better than others. It could be that the entire
game is written in C. Such a game would be much faster, but it
would be less flexible in that wizards could not add things to
the game while it was running. This is the theory behind DikuMUDs.
Instead, LPMUDs run on the theory that the driver should in no
define the nature of the game, that the nature of the game is
to be decided by the individuals involved, and that you should
be able to add to the game <I>as it is being played</I>. This
is why LPMUDs make use of the LPC programming language. It allows
you to define the nature of the game in LPC for the driver to
read and execute as needed. It is also a much simpler language
to understand than C, thus making the process of world creation
open to a greater number of people.
</p>
<p>
Once you have written a file in LPC (assuming it is correct LPC
), it just sits there on the host machine's hard drive until something
in the game makes reference to it. When something in the game
finally does make reference to the object, a copy of the file
is loaded into memory and a special function of that object is
called in order to initialize the values of the variables in the
object. Now, do not be concerned if that last sentence went right
over your head, since someone brand new to programming would not
know what the hell a function or a variable is. The important
thing to understand right now is that a copy of the object file
is taken by the driver from the machine's hard drive and stored
into memory (since it is a copy, multiple versions of that object
may exist). You will later understand what a function is, what
a variable is, and exactly how it is something in the game made
reference to your object.
</p>
<hr size="1">
<p><strong>Loading an object into memory</strong></p>
<p>
Although there is no particular place in an object code that must
exist in order for the driver to begin executing it, there is
a place for which the driver will search in order to initialize
the object. On compat drivers, it is the function called reset().
On native muds it is the function called create().
</p>
<p>
LPC objects are made up of variables (values which can change)
and functions which are used to manipulate those variables. Functions
manipulate variables through the use of LPC grammatical structures,
which include calling other functions, using externally defined
functions (efuns), and basic LPC expressions and flow control
mechanisms.
</p>
<p>
Does that sound convoluted? First lets start with a variable.
A variable might be something like: level. It can &quot;vary&quot;
from situation to situation in value, and different things use
the value of the player's level to make different things happen.
For instance, if you are a level 19 player, the value of the variable
level will be 19. Now if your mud is on the old LPMud 2.4.5 system
where levels 1-19 are players and 20+ are wizards, things can
ask for your level value to see if you can perform wizard type
actions. Basically, each object in LPC is a pile of variables
with values which change over time.
</p>
<p>
Things happen to these objects based on what values its variables
hold. Often, then things that happen cause the variables to change.
</p>
<p>
So, whenever an object in LPC is referenced by another object
currently in memory, the driver searches to see what places for
values the object has (but they have no values yet). Once that
is done, the driver calls a function in the object called reset()
or create() (depending on your driver) which will set up the starting
values for the object's variables. It is thus through calls to
functions that variable values get manipulated.
</p>
<p>
But create() or reset() is NOT the starting place of LPC code,
although it is where most LPC code execution does begin. The fact
is, those functions need not exist. If your object does just fine
with its starting values all being NULL pointers (meaning, for
our purposes here, 0), then you do not need a create() or reset()
function. Thus the first bit of execution of the object's code
may begin somewhere completely different.
</p>
<p>
Now we get to what this chapter is all about. The question: What
consists a complete LPC object? Well, an LPC object is simply
one or more functions grouped together manipulating 0 or more
variables. The order in which functions are placed in an object
relative to one another is irrelevant. In other words:
<pre>
void init() {
    add_action(&quot;smile&quot;, &quot;smile&quot;);
}

void create() {
    return;
}

int smile( string str ) {
    return 0;
}
</pre>
is exactly the same as:
<pre>
void create() {
    return;
}

int smile( string str ) {
    return 0;
}

void init() {
    add_action(&quot;smile&quot;, &quot;smile&quot;);
}
</pre>
Also important to note, the object containing only:
<pre>
void nonsense() {}
</pre>
is a valid, but trivial object, although it probably would not
interact properly with other objects on your mud since such an
object has no weight, is invisible, etc..
</p>
<hr size="1">
<p><strong>Chapter Summary</strong></p>
<p>
LPC code has no beginning point or ending point, since LPC code
is used to create objects to be used by the driver program rather
than create individual programs. LPC objects consist of one or
more functions whose order in the code is irrelevant, as well
as of zero or more variables whose values are manipulated inside
those functions. LPC objects simply sit on the host machine's
hard driver until referenced by another object in the game (in
other words, they do not really exist). Once the object is referenced,
it is loaded into the machine's memory with empty values for the
variables. The function reset() in compat muds or create() in
native muds is called in that object if it exists to allow the
variables to take on initial values. Other functions in the object
are used by the driver and other objects in the game to allow
interaction among objects and the manipulation of the LPC variables.
</p>
<p>
A note on reset() and create():
<blockquote>
create() is only used by muds in native mode (see the textbook
Introduction for more information on native mode vs. compat mode).
It is only used to initialize newly referenced objects.
</blockquote>
<blockquote>
reset() is used by both muds in compat mode and native mode. In
compat mode, reset() performs two functions. First, it is used
to initialize newly referenced objects. In addition, however,
compat mode muds use reset() to &quot;reset&quot; the object.
In other words, return it to its initial state of affairs. This
allows monsters to regenerate in a room and doors to start back
in the shut position, etc.. Native mode muds use reset() to perform
the second function (as its name implies).
</blockquote>
</p>
<p>
So there are two important things which happen in LP style muds
which cause the driver to make calls to functions in objects.
The first is the creation of the object. At this time, the driver
calls a function to initalize the values in the object. For compat
mode muds, this is performed by the function named reset() (with
an argument of 0, more on this later though). For muds running
in native mode, this is performed by the function create().
</p>
<p>
The second is the returning of the room to some base state of
affairs. This base set of affairs may or may not be different
from the initial state of affairs, and certainly you would not
want to take up time doing redundant things (like resetting variables
that never change). Compat mode muds nevertheless use the same
function that was used to create the object to reset it, that
being reset(). Native mode muds, who use create() to create the
room, instead use reset() to reset it. All is not lost in compat
mode though, as there is a way to tell the difference between
creation and resetting. For reset purposes, the driver passes
either 1 or the reset number as an argument to reset() in compat
mode. Now this is meaningless to you now, but just keep in mind
that you can in fact tell the difference in compat mode. Also
keep in mind that the argment in the creation use of reset is
0 and the argument in the reset use is a nonzero number.
</p>