dw_fluffos_v2/
dw_fluffos_v2/fluffos-2.9-ds2.05/
dw_fluffos_v2/fluffos-2.9-ds2.05/ChangeLog.old/
dw_fluffos_v2/fluffos-2.9-ds2.05/Win32/
dw_fluffos_v2/fluffos-2.9-ds2.05/compat/
dw_fluffos_v2/fluffos-2.9-ds2.05/compat/simuls/
dw_fluffos_v2/fluffos-2.9-ds2.05/include/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/clone/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/command/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/data/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/etc/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/include/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/inherit/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/inherit/master/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/log/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/compiler/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/efuns/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/operators/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/u/
dw_fluffos_v2/fluffos-2.9-ds2.05/tmp/
dw_fluffos_v2/fluffos-2.9-ds2.05/windows/
dw_fluffos_v2/lib/
dw_fluffos_v2/lib/binaries/cmds/
dw_fluffos_v2/lib/binaries/cmds/creator/
dw_fluffos_v2/lib/binaries/cmds/living/
dw_fluffos_v2/lib/binaries/cmds/player/
dw_fluffos_v2/lib/binaries/d/admin/obj/
dw_fluffos_v2/lib/binaries/d/liaison/
dw_fluffos_v2/lib/binaries/global/virtual/
dw_fluffos_v2/lib/binaries/global/virtual/setup_compiler/
dw_fluffos_v2/lib/binaries/obj/handlers/autodoc/
dw_fluffos_v2/lib/binaries/obj/handlers/terrain_things/
dw_fluffos_v2/lib/binaries/obj/misc/
dw_fluffos_v2/lib/binaries/obj/misc/buckets/
dw_fluffos_v2/lib/binaries/obj/monster/
dw_fluffos_v2/lib/binaries/obj/reactions/
dw_fluffos_v2/lib/binaries/obj/reagents/
dw_fluffos_v2/lib/binaries/secure/cmds/creator/
dw_fluffos_v2/lib/binaries/secure/master/
dw_fluffos_v2/lib/binaries/std/
dw_fluffos_v2/lib/binaries/std/dom/
dw_fluffos_v2/lib/binaries/std/effects/object/
dw_fluffos_v2/lib/binaries/std/guilds/
dw_fluffos_v2/lib/binaries/std/languages/
dw_fluffos_v2/lib/binaries/std/races/
dw_fluffos_v2/lib/binaries/std/room/
dw_fluffos_v2/lib/binaries/std/room/basic/
dw_fluffos_v2/lib/binaries/std/shops/
dw_fluffos_v2/lib/binaries/std/shops/inherit/
dw_fluffos_v2/lib/binaries/www/
dw_fluffos_v2/lib/cmds/guild-race/
dw_fluffos_v2/lib/cmds/guild-race/crafts/
dw_fluffos_v2/lib/cmds/guild-race/other/
dw_fluffos_v2/lib/cmds/playtester/
dw_fluffos_v2/lib/cmds/playtester/senior/
dw_fluffos_v2/lib/d/admin/
dw_fluffos_v2/lib/d/admin/log/
dw_fluffos_v2/lib/d/admin/mapper/31-10-01/mapmaker/event/
dw_fluffos_v2/lib/d/admin/meetings/
dw_fluffos_v2/lib/d/admin/obj/
dw_fluffos_v2/lib/d/admin/room/we_care/
dw_fluffos_v2/lib/d/admin/save/
dw_fluffos_v2/lib/d/dist/
dw_fluffos_v2/lib/d/dist/mtf/
dw_fluffos_v2/lib/d/dist/pumpkin/
dw_fluffos_v2/lib/d/dist/pumpkin/chars/
dw_fluffos_v2/lib/d/dist/pumpkin/desert/
dw_fluffos_v2/lib/d/dist/pumpkin/gumboot/
dw_fluffos_v2/lib/d/dist/pumpkin/hospital/
dw_fluffos_v2/lib/d/dist/pumpkin/inherit/
dw_fluffos_v2/lib/d/dist/pumpkin/map/
dw_fluffos_v2/lib/d/dist/pumpkin/plain/
dw_fluffos_v2/lib/d/dist/pumpkin/pumpkin/
dw_fluffos_v2/lib/d/dist/pumpkin/save/
dw_fluffos_v2/lib/d/dist/pumpkin/squash/
dw_fluffos_v2/lib/d/dist/pumpkin/terrain/
dw_fluffos_v2/lib/d/dist/pumpkin/woods/
dw_fluffos_v2/lib/d/dist/start/
dw_fluffos_v2/lib/d/learning/TinyTown/buildings/
dw_fluffos_v2/lib/d/learning/TinyTown/map/
dw_fluffos_v2/lib/d/learning/TinyTown/roads/
dw_fluffos_v2/lib/d/learning/add_command/
dw_fluffos_v2/lib/d/learning/arms_and_weps/
dw_fluffos_v2/lib/d/learning/chars/
dw_fluffos_v2/lib/d/learning/cutnpaste/
dw_fluffos_v2/lib/d/learning/examples/npcs/
dw_fluffos_v2/lib/d/learning/examples/player_houses/npcs/
dw_fluffos_v2/lib/d/learning/examples/terrain_map/basic/
dw_fluffos_v2/lib/d/learning/functions/
dw_fluffos_v2/lib/d/learning/handlers/
dw_fluffos_v2/lib/d/learning/help_topics/npcs/
dw_fluffos_v2/lib/d/learning/help_topics/objects/
dw_fluffos_v2/lib/d/learning/help_topics/rcs_demo/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/crowd/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/situations/
dw_fluffos_v2/lib/d/learning/items/
dw_fluffos_v2/lib/d/learning/save/
dw_fluffos_v2/lib/d/liaison/
dw_fluffos_v2/lib/d/liaison/NEWBIE/doc/
dw_fluffos_v2/lib/d/liaison/NEWBIE/save/oldlog/
dw_fluffos_v2/lib/db/
dw_fluffos_v2/lib/doc/
dw_fluffos_v2/lib/doc/creator/
dw_fluffos_v2/lib/doc/creator/autodoc/include/reaction/
dw_fluffos_v2/lib/doc/creator/autodoc/include/ritual_system/
dw_fluffos_v2/lib/doc/creator/autodoc/include/talker/
dw_fluffos_v2/lib/doc/creator/autodoc/include/terrain_map/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/baggage/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/clock/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/clothing/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/cont_save/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/corpse/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/money/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/monster/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/scabbard/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/service_provider/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/state_changer/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/wand/
dw_fluffos_v2/lib/doc/creator/autodoc/std/book_dir/
dw_fluffos_v2/lib/doc/creator/autodoc/std/key/
dw_fluffos_v2/lib/doc/creator/autodoc/std/learning/
dw_fluffos_v2/lib/doc/creator/autodoc/std/map/
dw_fluffos_v2/lib/doc/creator/autodoc/std/race/
dw_fluffos_v2/lib/doc/creator/autodoc/std/weapon_logic/
dw_fluffos_v2/lib/doc/creator/files/
dw_fluffos_v2/lib/doc/creator/policy/
dw_fluffos_v2/lib/doc/creator/room/
dw_fluffos_v2/lib/doc/effects/
dw_fluffos_v2/lib/doc/ideas/
dw_fluffos_v2/lib/doc/known_command/
dw_fluffos_v2/lib/doc/lpc/basic_manual/
dw_fluffos_v2/lib/doc/lpc/intermediate/
dw_fluffos_v2/lib/doc/new/add_command/
dw_fluffos_v2/lib/doc/new/handlers/
dw_fluffos_v2/lib/doc/new/living/
dw_fluffos_v2/lib/doc/new/living/race/
dw_fluffos_v2/lib/doc/new/living/spells/
dw_fluffos_v2/lib/doc/new/player/
dw_fluffos_v2/lib/doc/new/room/guild/
dw_fluffos_v2/lib/doc/new/room/outside/
dw_fluffos_v2/lib/doc/new/room/storeroom/
dw_fluffos_v2/lib/doc/object/
dw_fluffos_v2/lib/doc/playtesters/
dw_fluffos_v2/lib/doc/policy/
dw_fluffos_v2/lib/doc/weapons/
dw_fluffos_v2/lib/global/handlers/
dw_fluffos_v2/lib/global/virtual/setup_compiler/
dw_fluffos_v2/lib/include/
dw_fluffos_v2/lib/include/cmds/
dw_fluffos_v2/lib/include/effects/
dw_fluffos_v2/lib/include/npc/
dw_fluffos_v2/lib/include/shops/
dw_fluffos_v2/lib/net/daemon/chars/
dw_fluffos_v2/lib/net/inherit/
dw_fluffos_v2/lib/net/intermud3/
dw_fluffos_v2/lib/net/intermud3/services/
dw_fluffos_v2/lib/net/obj/
dw_fluffos_v2/lib/net/save/
dw_fluffos_v2/lib/net/smnmp/
dw_fluffos_v2/lib/net/snmp/
dw_fluffos_v2/lib/obj/amulets/
dw_fluffos_v2/lib/obj/b_day/
dw_fluffos_v2/lib/obj/examples/
dw_fluffos_v2/lib/obj/food/alcohol/
dw_fluffos_v2/lib/obj/food/chocolates/
dw_fluffos_v2/lib/obj/food/fruits/
dw_fluffos_v2/lib/obj/food/meat/
dw_fluffos_v2/lib/obj/food/nuts/
dw_fluffos_v2/lib/obj/food/seafood/
dw_fluffos_v2/lib/obj/food/vegetables/
dw_fluffos_v2/lib/obj/fungi/
dw_fluffos_v2/lib/obj/furnitures/artwork/
dw_fluffos_v2/lib/obj/furnitures/bathroom/
dw_fluffos_v2/lib/obj/furnitures/beds/
dw_fluffos_v2/lib/obj/furnitures/cabinets/
dw_fluffos_v2/lib/obj/furnitures/chairs/
dw_fluffos_v2/lib/obj/furnitures/chests/
dw_fluffos_v2/lib/obj/furnitures/clocks/
dw_fluffos_v2/lib/obj/furnitures/crockery/
dw_fluffos_v2/lib/obj/furnitures/cupboards/
dw_fluffos_v2/lib/obj/furnitures/cushions/
dw_fluffos_v2/lib/obj/furnitures/fake_plants/
dw_fluffos_v2/lib/obj/furnitures/lamps/
dw_fluffos_v2/lib/obj/furnitures/mirrors/
dw_fluffos_v2/lib/obj/furnitures/outdoor/
dw_fluffos_v2/lib/obj/furnitures/safes/
dw_fluffos_v2/lib/obj/furnitures/shelves/
dw_fluffos_v2/lib/obj/furnitures/sideboards/
dw_fluffos_v2/lib/obj/furnitures/sofas/
dw_fluffos_v2/lib/obj/furnitures/stoves/
dw_fluffos_v2/lib/obj/furnitures/tables/
dw_fluffos_v2/lib/obj/furnitures/wardrobes/
dw_fluffos_v2/lib/obj/handlers/
dw_fluffos_v2/lib/obj/handlers/autodoc/
dw_fluffos_v2/lib/obj/jewellery/anklets/
dw_fluffos_v2/lib/obj/jewellery/bracelets/
dw_fluffos_v2/lib/obj/jewellery/earrings/
dw_fluffos_v2/lib/obj/jewellery/misc/
dw_fluffos_v2/lib/obj/jewellery/necklaces/
dw_fluffos_v2/lib/obj/jewellery/rings/
dw_fluffos_v2/lib/obj/media/
dw_fluffos_v2/lib/obj/misc/buckets/
dw_fluffos_v2/lib/obj/misc/jars/
dw_fluffos_v2/lib/obj/misc/papers/
dw_fluffos_v2/lib/obj/misc/player_shop/
dw_fluffos_v2/lib/obj/misc/shops/
dw_fluffos_v2/lib/obj/misc/traps/
dw_fluffos_v2/lib/obj/monster/
dw_fluffos_v2/lib/obj/monster/godmother/
dw_fluffos_v2/lib/obj/monster/transport/
dw_fluffos_v2/lib/obj/plants/inherit/
dw_fluffos_v2/lib/obj/potions/
dw_fluffos_v2/lib/open/boards/
dw_fluffos_v2/lib/save/autodoc/
dw_fluffos_v2/lib/save/bank_accounts/
dw_fluffos_v2/lib/save/boards/frog/
dw_fluffos_v2/lib/save/books/bed_catalog/
dw_fluffos_v2/lib/save/creators/
dw_fluffos_v2/lib/save/mail/
dw_fluffos_v2/lib/save/mail/p/
dw_fluffos_v2/lib/save/soul/data/
dw_fluffos_v2/lib/save/tasks/
dw_fluffos_v2/lib/save/vaults/
dw_fluffos_v2/lib/secure/cmds/lord/
dw_fluffos_v2/lib/secure/config/
dw_fluffos_v2/lib/secure/items/
dw_fluffos_v2/lib/secure/player/
dw_fluffos_v2/lib/soul/
dw_fluffos_v2/lib/soul/i/
dw_fluffos_v2/lib/soul/j/
dw_fluffos_v2/lib/soul/k/
dw_fluffos_v2/lib/soul/o/
dw_fluffos_v2/lib/soul/q/
dw_fluffos_v2/lib/soul/to_approve/
dw_fluffos_v2/lib/soul/u/
dw_fluffos_v2/lib/soul/v/
dw_fluffos_v2/lib/soul/wish_list/
dw_fluffos_v2/lib/soul/y/
dw_fluffos_v2/lib/soul/z/
dw_fluffos_v2/lib/std/creator/
dw_fluffos_v2/lib/std/effects/
dw_fluffos_v2/lib/std/effects/attached/
dw_fluffos_v2/lib/std/effects/external/
dw_fluffos_v2/lib/std/effects/fighting/
dw_fluffos_v2/lib/std/effects/other/
dw_fluffos_v2/lib/std/environ/
dw_fluffos_v2/lib/std/guilds/
dw_fluffos_v2/lib/std/hospital/
dw_fluffos_v2/lib/std/house/
dw_fluffos_v2/lib/std/house/onebedhouse/
dw_fluffos_v2/lib/std/house/onebedhut/
dw_fluffos_v2/lib/std/house/tworoomflat/
dw_fluffos_v2/lib/std/languages/
dw_fluffos_v2/lib/std/liquids/
dw_fluffos_v2/lib/std/nationality/
dw_fluffos_v2/lib/std/nationality/accents/
dw_fluffos_v2/lib/std/nationality/accents/national/
dw_fluffos_v2/lib/std/nationality/accents/regional/
dw_fluffos_v2/lib/std/npc/goals/
dw_fluffos_v2/lib/std/npc/goals/basic/
dw_fluffos_v2/lib/std/npc/goals/misc/
dw_fluffos_v2/lib/std/npc/inherit/
dw_fluffos_v2/lib/std/npc/plans/
dw_fluffos_v2/lib/std/npc/plans/basic/
dw_fluffos_v2/lib/std/outsides/
dw_fluffos_v2/lib/std/races/shadows/
dw_fluffos_v2/lib/std/room/basic/topography/
dw_fluffos_v2/lib/std/room/controller/
dw_fluffos_v2/lib/std/room/controller/topography/
dw_fluffos_v2/lib/std/room/furniture/games/
dw_fluffos_v2/lib/std/room/furniture/inherit/
dw_fluffos_v2/lib/std/room/inherit/carriage/
dw_fluffos_v2/lib/std/room/inherit/topography/
dw_fluffos_v2/lib/std/room/punishments/
dw_fluffos_v2/lib/std/room/topography/area/
dw_fluffos_v2/lib/std/room/topography/iroom/
dw_fluffos_v2/lib/std/room/topography/milestone/
dw_fluffos_v2/lib/std/shadows/
dw_fluffos_v2/lib/std/shadows/attached/
dw_fluffos_v2/lib/std/shadows/curses/
dw_fluffos_v2/lib/std/shadows/disease/
dw_fluffos_v2/lib/std/shadows/fighting/
dw_fluffos_v2/lib/std/shadows/room/
dw_fluffos_v2/lib/std/shops/controllers/
dw_fluffos_v2/lib/std/shops/objs/
dw_fluffos_v2/lib/std/shops/player_shop/
dw_fluffos_v2/lib/std/shops/player_shop/office_code/
dw_fluffos_v2/lib/std/socket/
dw_fluffos_v2/lib/www/
dw_fluffos_v2/lib/www/external/autodoc/
dw_fluffos_v2/lib/www/external/java/telnet/Documentation/
dw_fluffos_v2/lib/www/external/java/telnet/Documentation/images/
dw_fluffos_v2/lib/www/external/java/telnet/examples/
dw_fluffos_v2/lib/www/external/java/telnet/tools/
dw_fluffos_v2/lib/www/pics/
dw_fluffos_v2/lib/www/secure/creator/
dw_fluffos_v2/lib/www/secure/editors/
dw_fluffos_v2/lib/www/secure/survey_results/
dw_fluffos_v2/win32/
<html><!-- #BeginTemplate "/Templates/Body Text.dwt" -->
<head>
<title> Discworld Documentation </title>
</head>
<body bgcolor="#ffffff" TEXT="#000030" LINK="#4a529c" VLINK="#b57339">
<table width="75%" border="0">
  <tr>
    <td><font face="arial,helvetica"><img align=left src="http://discworld.imaginary.com/external//pics/dw4.gif"></font></td>
    <td><font face="arial,helvetica">
      <h2>Discworld Documentation:</h2>
      <h2>LPC for Dummies</h2>
      </font> 
      <p><font size="+1"><!-- #BeginEditable "Title" --><font size="+1"><b>Chapter One: 
  Overview of LPC</b></font><!-- #EndEditable --></font></p>
      <p><i>N.B - This is a work in progress... a living document if you like. 
        If it appears to be dead when you view it, don't worry. It's most likely 
        just playing possum.</i></p>
      <p>Comments on these chapters and tutorials can be e-mailed to <a href="mailto:drakkos@cableinet.co.uk">Drakkos.</a></p>
    </td>
  </tr>
</table>
<br>
<!-- #BeginEditable "Body" --> <p><b>Introduction</b></p><p> LPC is an interpreted MUD language created by Lars Pensjoe for his LPMUD, 
  an interactive multi-user environment. LPC is suitable for many purposes, but 
  is especially suited to the creation of games such as Multi User Dungeons. Since 
  its first appearance in 1988, the sophistication and popularity of the language 
  has increased dramatically.</p>
<p> LPC is like the programming language C in certain respects. It isn't quite 
  as free-form as C, but it does offer a development environment extremely well 
  suited to creating multi-user dungeons. Here is where you, as a creator, come 
  in.</p>
<p>When writing a program for a computer, it is necessary to convert the language 
  being used into the primitive grunts and whistles that the machine itself understands. 
  Computers, at the lowest levels, understand only binary (1s and 0s). Obviously, 
  coding a complicated program in binary would be extremely time-consuming and 
  thoroughly mind-bending... and so, programming languages were created to allow 
  for computers to be programmed in a language that was easier to learn. </p>
<p><b>High and Low Level Languages</b></p>
<p>Low level languages, such as Assembler, aren't all that incredibly different 
  from the signals the computer itself understands. Coding in a low level language 
  takes time and a good understanding of how the internals of a computer work.</p>
<p> An assembler program may look something like the following example. Don' t 
  worry about understanding it... you won't need to comprehend how this works... 
  it is included merely as an example:</p>
<blockquote> 
  <div align="center"> 
    <div align="left"> <code>mov ax,0006</code></div>
  </div>
  <div align="center"> 
    <div align="left"> <code>mov bx,0002</code></div>
  </div>
  <div align="center"> 
    <div align="left"> <code>add ax,bx </code></div>
  </div>
</blockquote>
<p>What this program does is move the value 0006 into the register the computer 
  understands as 'ax', then moves the value 0002 into the register the computer 
  understands as 'bx'. It then adds the contents of registers 'ax' and 'bx' together. 
</p>
<p>As you can see, coding in assembler requires quite a bit of work to just add 
  two numbers together.</p>
<p> High Level languages, on the other hand, are written using languages somewhat 
  more similar to the language we speak. Mainly they use english syntax to build 
  complex instructions for the computer. A very well known example of a high level 
  language is BASIC (Beginners All-Purpose Symbolic Instruction Code).</p>
<p> An example of adding two numbers together in a high level language would simply 
  be: </p>
<blockquote> 
  <p><code>value = 6 + 2</code></p>
</blockquote>
<p> As you can see, this is much easier to follow, and does not require any knowledge 
  of how the computer is accomplishing the task at a machine level.</p>
<p> Languages such as C and Pascal fall a little between these two extremes, and 
  so are often referred to as Mid Level languages. In order for the computer to 
  understand a high level language, it is necessary for the code to be converted 
  into machine language. This occurs in two main ways.</p>
<p> <b>Compilation, and Interpretation.</b></p>
<p>In compiled languages, you type up some source code in the high level syntax, 
  then 'compile' it. The compiler takes your code, and converts it into machine 
  language, producing an executable file at the end. You then run this file, and 
  if it works, great! If not, you need to re-edit the source code, and then recompile.</p>
<p> Interpreted languages, on the other hand, work by converting the code into 
  machine language as it is executed. This is obviously much slower than with 
  a compiled language, but does allow for changes to be made without requiring 
  the whole file to be recompiled. Statements are executed one after another, 
  and then forgotten about.</p>
<p> Well... this isn't entirely true in the case of LPC. LPC is an 'object orientated' 
  language... each piece of code you write is potentially an object. Put simply, 
  an object is a program that has been loaded into memory. The first time an object 
  is loaded, it becomes the 'master object'. When this master object is created, 
  it is translated from high level LPC into an intermediate language suitable 
  for speedy interpretation when the game is running. All 'clones' of this object 
  are then made from this master object.</p>
<p> Take the following example: </p>
<p>There is a file, 'Monster', which contains all the code necessary for creating 
  your very own critter. When the 'monster' object is loaded, it becomes the 'master' 
  object for monster, and is semi-compiled by the driver (more on the driver later). 
  When you create your own monster, it makes a copy of the master object, and 
  gives your new monster a chunk of the computer's memory to deal with the new 
  object. We will explain why this is necessary later on when we come to talk 
  about data types.</p>
<p> <b>The Driver and the Mudlib </b></p>
<p>Before we do that, we need to cover what exactly we mean by the terms 'mudlib', 
  and 'driver'. You'll come across these terms rather often as a creator, so it 
  is necessary to make sure you fully understand them now. </p>
<p>Essentially, the driver is a piece of very low level code that deals with all 
  the things necessary to keep the mud running. For example, the driver deals 
  with the network connections when people log on to the MUD, and makes sure the 
  proper login connections are made. It also deals with creating new objects, 
  and destroying objects when they are no longer being used. It is the driver 
  that interprets your LPC code to make all sorts of groovy things happen. The 
  driver also provides a library of functions called 'efuns' which are very useful 
  when coding. We will discuss these in more detail when we start to talk about 
  LPC functions. All you really need to understand about the driver is that it's 
  somewhat like a mini-operating system for the MUD.</p>
<p> The mudlib, on the other hand, is simply the collection of LPC objects that 
  make up the basic environment of the MUD. On Discworld, this is essentially 
  all code outside of /w/ and /d/. For example, the objects that make up rooms, 
  monsters, and weapons all belong to the mudlib.</p>
<p> The relationship between the mudlib and the driver can be summed up as: The 
  mudlib knows what to do, but has no idea how to do it. The driver knows how 
  to do it, but has no idea what to do. The mudlib and driver are co-dependant, 
  and from the combination of the two comes the basic structure of the MUD itself. 
</p>
<p><b>The Preprocessor.</b></p>
<p> The preprocessor is not actually a part of LPC. What it is is a clever string 
  substituter that is run before an object actually compiles. If you have a look 
  at some of the code we have on Discworld, you'll see many of them are peppered 
  with lines that begin with the symbol '#'. These are not actually LPC statements. 
  Instead, they are 'preprocessor directives'... secretive instructions that are 
  handled before an object ever compiles.</p>
<p> You won't need to think too much about how this works. Just so long as you 
  know that it happens. You will need, however, to understand how two of the most 
  common directives are used. </p>
<p>The first of these is #include. This does exactly what it says it does... it 
  simply dumps a copy of a file in place of the #include line. Generally these 
  files are called 'header files', and are denoted with a .h extension to the 
  filename. The filename will need to be enclosed in either quotation marks (""), 
  or angle braces (<>). The difference here is purely in which order the preprocessor 
  will look for the file. If you enclose it in quotation marks, it will look in 
  the current directory for the file. If it doesn't find it, it then looks in 
  the standard include directory (On Discworld, this is /include/). If enclosed 
  in angle braces, it will search in the opposite order... first in /include/, 
  and if it doesn't find it there, then in the current working directory. </p>
<p>For example: </p>
<blockquote> 
  <p><code>#include "my_header.h" </code></p>
</blockquote>
<p>Will search the current directory for a file called 'my_header.h'. If it doesn't 
  find it there, it will then search /include/ for a file called 'my_header.h'. 
  If it finds the file, it will then replace the #include line with the contents 
  of it.</p>
<p> The next preprocessor directive you are likely to come across is the #define 
  directive, and this takes the form:</p>
<blockquote> 
  <p> <code>#define NAME "drakkos" </code></p>
</blockquote>
<p>When the preprocessor comes to this line, it will search through the code for 
  any occurrence of the text NAME, and replace it with the text "drakkos". This 
  is extremely useful for defining things such as filenames, since it means a 
  filename which is used throughout your code can be changed simply by altering 
  the #define.</p>
<p> #include files are often used mainly as a collection of related #defines... 
  think of it as a collection of shortcuts that can be used instead of the real 
  values or file-names.</p>
<p> Now, let's take a look at the preprocessor in action on a small piece of code. 
  Let's say we have a header file, my_header.h, that consists of the following 
  code:</p>
<blockquote> 
  <div align="left"> <code>#define NAME "drakkos" </code></div>
  <code>#define MUD "Discworld" </code> 
  <div align="left"> <code>#define VALUE "10</code>"</div>
</blockquote>
<p> And say we have a piece of code such as the following: </p>
<blockquote> 
  <p><code>#include "my_header.h" </code></p>
  <div align="left"><code>write("My name is " + NAME);</code></div>
  <div align="left"><code>write("I am a creator on " + MUD);</code></div>
  <div align="left"><code>write("I am " + VALUE + " years old."); </code></div>
</blockquote>
<p>Now, let's look in stages at what the preprocessor does. First, it comes to 
  the line #include "my_header.h". So it looks in our current directory for the 
  file, and lo and behold, there it is. So it dumps this file in place of the 
  #include statement:</p>
<blockquote> 
  <div align="left"> <code>#define NAME "drakkos" </code></div>
  <div align="left"><code>#define MUD "Discworld" </code></div>
  <div align="left"><code>#define VALUE "10" </code> </div>
  <div align="left"><code><br>
    write("My name is " + NAME);</code></div>
  <div align="left"><code> write("I am a creator on " + MUD);</code></div>
  <div align="left"><code> write("I am " + VALUE + " years old."); </code></div>
</blockquote>
<p>It then comes to the first #define statement. It searches through the code 
  for occurrences of NAME, and replaces it with "drakkos":</p>
<blockquote> 
  <div align="left"><code>#define NAME "drakkos" </code></div>
  <div align="left"><code>#define MUD "Discworld" </code></div>
  <div align="left"><code>#define VALUE "10"</code></div>
  <div align="left"><code><br>
    write("My name is " + "drakkos"); </code></div>
  <div align="left"><code>write("I am a creator on " + MUD);</code></div>
  <div align="left"><code> write("I am " + VALUE + " years old.");</code></div>
</blockquote>
<p> Then the next define, where it replaces MUD with "Discworld": </p>
<blockquote> 
  <div align="left"><code>#define NAME "drakkos"</code></div>
  <div align="left"><code> #define MUD "Discworld"</code></div>
  <div align="left"><code> #define VALUE "10"</code></div>
  <div align="left"><code> <br>
    write("My name is " + "drakkos");</code></div>
  <div align="left"><code> write("I am a creator on " + "Discworld");</code></div>
  <div align="left"><code> write("I am " + VALUE + " years old.");</code></div>
</blockquote>
<p> And then VALUE with "10": </p>
<blockquote> 
  <div align="left"><code><font face="Courier New, Courier, mono">#define NAME 
    "drakkos" </font></code></div>
  <div align="left"><font face="Courier New, Courier, mono"><code>#define MUD 
    "Discworld"</code></font></div>
  <div align="left"><font face="Courier New, Courier, mono"><code> #define VALUE 
    "10&quot;</code></font></div>
  <div align="left"><font face="Courier New, Courier, mono"><code> <br>
    write("My name is " + "drakkos"); </code></font></div>
  <div align="left"><font face="Courier New, Courier, mono"><code>write("I am 
    a creator on " + "Discworld"); </code></font></div>
  <div align="left"><font face="Courier New, Courier, mono"><code>write("I am 
    " + "10" + " years old."); </code></font></div>
</blockquote>
<p>There are other directives that have not been discussed here... these are much 
  rarer and generally you will not have cause to use them in day to day creating. 
  As long as you understand how #define and #include work, you're well on your 
  way to appreciating what the preprocessor does. </p>
<p><b>Chapter Summary</b></p>
<p> In this chapter, you should hopefully be comfortable with the difference between 
  the mudlib and the driver, and compiled/interpreted languages. You should also 
  be comfortable with the use of #include and #define in objects, and how these 
  can be used to develop portable and easily modified code.</p>
<ul>
  <li> <font face="Courier New, Courier, mono">High level languages are used to 
    abstract code away from the machine details of implementation.</font></li>
  <li><font face="Courier New, Courier, mono">Compiled languages are compiled 
    into machine code before execution.</font></li>
  <li><font face="Courier New, Courier, mono"> Interpreted languages are executed 
    statement by statement without ever being compiled.</font></li>
  <li><font face="Courier New, Courier, mono"> LPC is a semi-interpreted language. 
    Master objects are compiled into an intermediate language and then interpreted 
    from there.</font></li>
  <li><font face="Courier New, Courier, mono"> The driver is what interprets LPC 
    code. It can be thought of as a mini- operating system for the MUD.</font></li>
  <li><font face="Courier New, Courier, mono"> The mudlib comprises of the code 
    used to create the environment of the MUD. Generally all the code outside 
    of /w/ and /d/</font></li>
  <li><font face="Courier New, Courier, mono"> The preprocessor is a clever string 
    substitution routine that runs before a master object is compiled. </font></li>
  <li><font face="Courier New, Courier, mono">Preprocessor directives are prefaced 
    with a '#' symbol.</font></li>
  <li><font face="Courier New, Courier, mono"> #include dumps the contents of 
    a file in place of the directive.</font></li>
  <li><font face="Courier New, Courier, mono">#define allows for all occurrences 
    of the defined text to be replaced with another value..</font></li>
  <li><font face="Courier New, Courier, mono">Header files (.h files) can be used 
    as a collection of conceptually related #defines, allowing for all objects 
    to share common #defines. </font></li>
</ul>
<!-- #EndEditable --> 
<p>
<hr>
<center><font size="-1"><a href="/login.html">Discworld MUD</a>'s world wide web pages.<br>brought to you by<br>
  <strong>Cut Me Own Throat Dibbler's <a href="/sausages.html">Sensational Sausages</a>;&nbsp;buy 
  one while they are hot.</strong> <br>
<hr>Lost?  Try Discworld's <a href="/">home page</a>.</font></center><font size="-1"><i><a href="mailto:drakkos@cableinet.co.uk"><font size="-2">Mail Drakkos!</font></a></i>
</font>
</body>
<!-- #EndTemplate --></html>