skylib_mudos_v1/
skylib_mudos_v1/bin/
skylib_mudos_v1/bin/db/
skylib_mudos_v1/mudlib/banish/a/
skylib_mudos_v1/mudlib/banish/b/
skylib_mudos_v1/mudlib/banish/c/
skylib_mudos_v1/mudlib/banish/d/
skylib_mudos_v1/mudlib/banish/e/
skylib_mudos_v1/mudlib/banish/f/
skylib_mudos_v1/mudlib/banish/g/
skylib_mudos_v1/mudlib/banish/h/
skylib_mudos_v1/mudlib/banish/j/
skylib_mudos_v1/mudlib/banish/l/
skylib_mudos_v1/mudlib/banish/m/
skylib_mudos_v1/mudlib/banish/n/
skylib_mudos_v1/mudlib/banish/o/
skylib_mudos_v1/mudlib/banish/p/
skylib_mudos_v1/mudlib/banish/r/
skylib_mudos_v1/mudlib/banish/s/
skylib_mudos_v1/mudlib/banish/t/
skylib_mudos_v1/mudlib/banish/u/
skylib_mudos_v1/mudlib/banish/w/
skylib_mudos_v1/mudlib/cmds/
skylib_mudos_v1/mudlib/cmds/admin/
skylib_mudos_v1/mudlib/cmds/guild-race/
skylib_mudos_v1/mudlib/cmds/guild-race/crafts/
skylib_mudos_v1/mudlib/cmds/guild-race/magic/
skylib_mudos_v1/mudlib/cmds/guild-race/other/
skylib_mudos_v1/mudlib/cmds/living/broken/
skylib_mudos_v1/mudlib/cmds/player/group_cmds/
skylib_mudos_v1/mudlib/d/admin/
skylib_mudos_v1/mudlib/d/admin/room/
skylib_mudos_v1/mudlib/d/admin/room/we_care/
skylib_mudos_v1/mudlib/d/admin/save/
skylib_mudos_v1/mudlib/d/admin/text/
skylib_mudos_v1/mudlib/d/learning/TinyTown/buildings/
skylib_mudos_v1/mudlib/d/learning/TinyTown/map/
skylib_mudos_v1/mudlib/d/learning/TinyTown/roads/
skylib_mudos_v1/mudlib/d/learning/chars/
skylib_mudos_v1/mudlib/d/learning/functions/
skylib_mudos_v1/mudlib/d/learning/handlers/
skylib_mudos_v1/mudlib/d/learning/help_topics/
skylib_mudos_v1/mudlib/d/learning/help_topics/npcs/
skylib_mudos_v1/mudlib/d/learning/help_topics/objects/
skylib_mudos_v1/mudlib/d/learning/help_topics/rcs_demo/
skylib_mudos_v1/mudlib/d/learning/help_topics/rcs_demo/RCS/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/crowd/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/situations/
skylib_mudos_v1/mudlib/d/learning/save/
skylib_mudos_v1/mudlib/d/learning/school/
skylib_mudos_v1/mudlib/d/learning/school/add_sc/
skylib_mudos_v1/mudlib/d/learning/school/characters/
skylib_mudos_v1/mudlib/d/learning/school/general/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/basic_commands/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/edtutor/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/unix_tutor/
skylib_mudos_v1/mudlib/d/learning/school/items/
skylib_mudos_v1/mudlib/d/learning/school/npc_school/
skylib_mudos_v1/mudlib/d/learning/school/room_school/
skylib_mudos_v1/mudlib/d/learning/school/room_school/room_basic/
skylib_mudos_v1/mudlib/d/learning/school/room_school/situations/
skylib_mudos_v1/mudlib/d/learning/school/room_school/terrain_tutor/
skylib_mudos_v1/mudlib/d/learning/text/
skylib_mudos_v1/mudlib/d/liaison/
skylib_mudos_v1/mudlib/d/mudlib/
skylib_mudos_v1/mudlib/d/mudlib/changes/
skylib_mudos_v1/mudlib/d/playtesters/
skylib_mudos_v1/mudlib/d/playtesters/effects/
skylib_mudos_v1/mudlib/d/playtesters/handlers/
skylib_mudos_v1/mudlib/d/playtesters/items/
skylib_mudos_v1/mudlib/d/sage/
skylib_mudos_v1/mudlib/doc/
skylib_mudos_v1/mudlib/doc/creator/
skylib_mudos_v1/mudlib/doc/driver/
skylib_mudos_v1/mudlib/doc/driver/efuns/arrays/
skylib_mudos_v1/mudlib/doc/driver/efuns/buffers/
skylib_mudos_v1/mudlib/doc/driver/efuns/compile/
skylib_mudos_v1/mudlib/doc/driver/efuns/filesystem/
skylib_mudos_v1/mudlib/doc/driver/efuns/floats/
skylib_mudos_v1/mudlib/doc/driver/efuns/functions/
skylib_mudos_v1/mudlib/doc/driver/efuns/general/
skylib_mudos_v1/mudlib/doc/driver/efuns/mappings/
skylib_mudos_v1/mudlib/doc/driver/efuns/mixed/
skylib_mudos_v1/mudlib/doc/driver/efuns/mudlib/
skylib_mudos_v1/mudlib/doc/driver/efuns/numbers/
skylib_mudos_v1/mudlib/doc/driver/efuns/parsing/
skylib_mudos_v1/mudlib/doc/known_command/
skylib_mudos_v1/mudlib/doc/login/
skylib_mudos_v1/mudlib/doc/lpc/basic_manual/
skylib_mudos_v1/mudlib/doc/lpc/intermediate/
skylib_mudos_v1/mudlib/doc/new/add_command/
skylib_mudos_v1/mudlib/doc/new/events/
skylib_mudos_v1/mudlib/doc/new/handlers/
skylib_mudos_v1/mudlib/doc/new/living/race/
skylib_mudos_v1/mudlib/doc/new/living/spells/
skylib_mudos_v1/mudlib/doc/new/object/
skylib_mudos_v1/mudlib/doc/new/player/
skylib_mudos_v1/mudlib/doc/new/room/guild/
skylib_mudos_v1/mudlib/doc/new/room/outside/
skylib_mudos_v1/mudlib/doc/new/room/storeroom/
skylib_mudos_v1/mudlib/doc/object/
skylib_mudos_v1/mudlib/doc/playtesters/
skylib_mudos_v1/mudlib/doc/policy/
skylib_mudos_v1/mudlib/doc/weapons/
skylib_mudos_v1/mudlib/global/
skylib_mudos_v1/mudlib/global/creator/
skylib_mudos_v1/mudlib/global/handlers/
skylib_mudos_v1/mudlib/global/virtual/setup_compiler/
skylib_mudos_v1/mudlib/include/cmds/
skylib_mudos_v1/mudlib/include/effects/
skylib_mudos_v1/mudlib/include/npc/
skylib_mudos_v1/mudlib/include/room/
skylib_mudos_v1/mudlib/include/shops/
skylib_mudos_v1/mudlib/net/daemon/
skylib_mudos_v1/mudlib/net/daemon/chars/
skylib_mudos_v1/mudlib/net/inherit/
skylib_mudos_v1/mudlib/net/obj/
skylib_mudos_v1/mudlib/obj/amulets/
skylib_mudos_v1/mudlib/obj/b_day/
skylib_mudos_v1/mudlib/obj/clothes/
skylib_mudos_v1/mudlib/obj/dwarmours/plate/
skylib_mudos_v1/mudlib/obj/dwclothes/transport/horse/
skylib_mudos_v1/mudlib/obj/dwscabbards/
skylib_mudos_v1/mudlib/obj/dwweapons/axes/
skylib_mudos_v1/mudlib/obj/dwweapons/chains/
skylib_mudos_v1/mudlib/obj/faith/symbols/
skylib_mudos_v1/mudlib/obj/fungi/
skylib_mudos_v1/mudlib/obj/gatherables/
skylib_mudos_v1/mudlib/obj/instruments/
skylib_mudos_v1/mudlib/obj/magic/
skylib_mudos_v1/mudlib/obj/media/
skylib_mudos_v1/mudlib/obj/misc/player_shop/
skylib_mudos_v1/mudlib/obj/monster/godmother/
skylib_mudos_v1/mudlib/obj/monster/transport/
skylib_mudos_v1/mudlib/obj/rings/
skylib_mudos_v1/mudlib/obj/spells/
skylib_mudos_v1/mudlib/obj/stationery/
skylib_mudos_v1/mudlib/obj/stationery/envelopes/
skylib_mudos_v1/mudlib/obj/stationery/papers/
skylib_mudos_v1/mudlib/obj/toys/
skylib_mudos_v1/mudlib/obj/vessels/
skylib_mudos_v1/mudlib/obj/weapons/swords/
skylib_mudos_v1/mudlib/save/autodoc/
skylib_mudos_v1/mudlib/save/leaflets/
skylib_mudos_v1/mudlib/save/mail/
skylib_mudos_v1/mudlib/save/new_soul/data/
skylib_mudos_v1/mudlib/save/parcels/
skylib_mudos_v1/mudlib/save/playerinfo/
skylib_mudos_v1/mudlib/save/players/d/
skylib_mudos_v1/mudlib/save/random_names/
skylib_mudos_v1/mudlib/save/random_names/data/
skylib_mudos_v1/mudlib/save/terrains/
skylib_mudos_v1/mudlib/save/terrains/tutorial_desert/
skylib_mudos_v1/mudlib/save/terrains/tutorial_grassy_field/
skylib_mudos_v1/mudlib/save/terrains/tutorial_mountain/
skylib_mudos_v1/mudlib/save/todo_lists/
skylib_mudos_v1/mudlib/secure/
skylib_mudos_v1/mudlib/secure/cmds/admin/
skylib_mudos_v1/mudlib/secure/cmds/lord/
skylib_mudos_v1/mudlib/secure/config/
skylib_mudos_v1/mudlib/secure/handlers/autodoc/
skylib_mudos_v1/mudlib/secure/handlers/intermud/
skylib_mudos_v1/mudlib/secure/include/global/
skylib_mudos_v1/mudlib/secure/save/
skylib_mudos_v1/mudlib/secure/save/handlers/
skylib_mudos_v1/mudlib/secure/std/classes/
skylib_mudos_v1/mudlib/secure/std/modules/
skylib_mudos_v1/mudlib/std/commands/
skylib_mudos_v1/mudlib/std/commands/shadows/
skylib_mudos_v1/mudlib/std/creator/
skylib_mudos_v1/mudlib/std/dom/
skylib_mudos_v1/mudlib/std/effects/
skylib_mudos_v1/mudlib/std/effects/external/
skylib_mudos_v1/mudlib/std/effects/fighting/
skylib_mudos_v1/mudlib/std/effects/priest/
skylib_mudos_v1/mudlib/std/effects/room/
skylib_mudos_v1/mudlib/std/environ/
skylib_mudos_v1/mudlib/std/guilds/
skylib_mudos_v1/mudlib/std/guilds/old/
skylib_mudos_v1/mudlib/std/languages/
skylib_mudos_v1/mudlib/std/languages/BACKUPS/
skylib_mudos_v1/mudlib/std/liquids/
skylib_mudos_v1/mudlib/std/npc/
skylib_mudos_v1/mudlib/std/npc/goals/
skylib_mudos_v1/mudlib/std/npc/goals/basic/
skylib_mudos_v1/mudlib/std/npc/goals/misc/
skylib_mudos_v1/mudlib/std/npc/plans/
skylib_mudos_v1/mudlib/std/npc/plans/basic/
skylib_mudos_v1/mudlib/std/npc/types/
skylib_mudos_v1/mudlib/std/npc/types/helper/
skylib_mudos_v1/mudlib/std/npcs/
skylib_mudos_v1/mudlib/std/outsides/
skylib_mudos_v1/mudlib/std/races/shadows/
skylib_mudos_v1/mudlib/std/room/basic/topography/
skylib_mudos_v1/mudlib/std/room/controller/
skylib_mudos_v1/mudlib/std/room/inherit/topography/
skylib_mudos_v1/mudlib/std/room/topography/area/
skylib_mudos_v1/mudlib/std/room/topography/iroom/
skylib_mudos_v1/mudlib/std/room/topography/milestone/
skylib_mudos_v1/mudlib/std/shadows/curses/
skylib_mudos_v1/mudlib/std/shadows/disease/
skylib_mudos_v1/mudlib/std/shadows/fighting/
skylib_mudos_v1/mudlib/std/shadows/healing/
skylib_mudos_v1/mudlib/std/shadows/magic/
skylib_mudos_v1/mudlib/std/shadows/poison/
skylib_mudos_v1/mudlib/std/shadows/rituals/
skylib_mudos_v1/mudlib/std/shadows/room/
skylib_mudos_v1/mudlib/std/shops/controllers/
skylib_mudos_v1/mudlib/std/shops/objs/
skylib_mudos_v1/mudlib/std/shops/player_shop/
skylib_mudos_v1/mudlib/std/socket/
skylib_mudos_v1/mudlib/std/soul/
skylib_mudos_v1/mudlib/std/soul/d/
skylib_mudos_v1/mudlib/std/soul/e/
skylib_mudos_v1/mudlib/std/soul/i/
skylib_mudos_v1/mudlib/std/soul/j/
skylib_mudos_v1/mudlib/std/soul/k/
skylib_mudos_v1/mudlib/std/soul/l/
skylib_mudos_v1/mudlib/std/soul/n/
skylib_mudos_v1/mudlib/std/soul/o/
skylib_mudos_v1/mudlib/std/soul/q/
skylib_mudos_v1/mudlib/std/soul/u/
skylib_mudos_v1/mudlib/std/soul/v/
skylib_mudos_v1/mudlib/std/soul/y/
skylib_mudos_v1/mudlib/std/soul/z/
skylib_mudos_v1/mudlib/std/stationery/
skylib_mudos_v1/mudlib/w/
skylib_mudos_v1/mudlib/w/default/
skylib_mudos_v1/mudlib/w/default/armour/
skylib_mudos_v1/mudlib/w/default/clothes/
skylib_mudos_v1/mudlib/w/default/item/
skylib_mudos_v1/mudlib/w/default/npc/
skylib_mudos_v1/mudlib/w/default/room/
skylib_mudos_v1/mudlib/w/default/weapon/
skylib_mudos_v1/mudlib/www/
skylib_mudos_v1/mudlib/www/download/
skylib_mudos_v1/mudlib/www/java/
skylib_mudos_v1/mudlib/www/secure/
skylib_mudos_v1/mudlib/www/secure/lpc/advanced/
skylib_mudos_v1/mudlib/www/secure/lpc/intermediate/
skylib_mudos_v1/v22.2b14-DSv10/
skylib_mudos_v1/v22.2b14-DSv10/ChangeLog.old/
skylib_mudos_v1/v22.2b14-DSv10/Win32/
skylib_mudos_v1/v22.2b14-DSv10/compat/
skylib_mudos_v1/v22.2b14-DSv10/compat/simuls/
skylib_mudos_v1/v22.2b14-DSv10/include/
skylib_mudos_v1/v22.2b14-DSv10/mudlib/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/clone/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/command/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/data/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/etc/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/include/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/inherit/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/inherit/master/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/log/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/compiler/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/efuns/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/operators/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/u/
skylib_mudos_v1/v22.2b14-DSv10/tmp/
skylib_mudos_v1/v22.2b14-DSv10/windows/
<h3>Chapter 3: LPC Data Types</h3>
<p><strong>What you should know by now</strong></p>
<p>
LPC object are made up of zero or more variables manipulated by
one or more functions. The order in which these functions appear
in code is irrelevant. The driver uses the LPC code you write
by loading copies of it into memory whenever it is first referenced
and additional copies through cloning. When each object is loaded
into memory, all the variables initially point to no value. The
reset() function in compat muds, and create() in native muds are
used to give initial values to variables in objects. The function
for creation is called immediately after the object is loaded
into memory. However, if you are reading this textbook with no
prior programming experience, you may not know what a function
is or how it gets called. And even if you have programming experience,
you may be wondering how the process of functions calling each
other gets started in newly created objects. Before any of these
questions get answered, however, you need to know more about what
it is the functions are manipulating. You therefore should thoroughly
come to know the concept behind LPC data types. Certainly the
most boring subject in this manual, yet it is the most crucial,
as 90% of all errors (excepting misplaced {} and ()) involve the
improper usage of LPC data types. So bear through this important
chapter, because it is my feeling that understanding this chapter
alone can help you find coding much, much easier.
</p>
<hr size="1">
<p><strong>Communicating with the computer</strong></p>
<p>
You possibly already know that computers cannot understand the
letters and numbers used by humans. Instead, the &quot;language&quot;
spoken by computers consists of an &quot;alphabet&quot; of 0's
and 1's. Certainly you know computers do not understand natural
human languages. But in fact, they do not understand the computer
languages we write for them either. Computer languages like BASIC,
C, C++, Pascal, etc. are all intermediate languages. They allow
you to structure your thoughts more coherently for translation
into the 0's and 1's of the computer's languages.
</p>
<p>
There are two methods in which translation is done: compilation
and interpretation. These simply are differences between when
the  programming language is translated into computer language.
With compiled languages, the programmer writes the code then uses
a program called a compiler to translate the program into the
computer's language. This translation occurs before the program
is run. With interpreted languages however, the process of translation
occurs as the program is being run. Since the translation of the program
is occurring during the time of the program's running in interpreted
languages, interpreted languages make much slower programs than
compiled languages.
</p>
<p>
The bottom line is, no matter what language you are writing in,
at some point this has to be changed into 0's and 1's which can
be understood by the computer. But the variables which you store
in memory are not simply 0's and 1's. So you have to have a way
in your programming languages of telling the computer whether
or not the 0's and 1's should be treated as decimal numbers or
characters or strings or anything else. You do this through the
use of data types.
</p>
<p>
For example, say you have a variable which you call 'x' and you
give it the decimal whole number value 65. In LPC you would do
this through the statement:
<pre>
x = 65;
</pre>
You can later do things like:
<pre>
write( x + &quot;\n&quot;); /* \n symbolically represents a carriage return */
y = x + 5;
</pre>
The first line allows you to send 65 and a carriage return to
someone's screen. The second line lets you set the value of y
to 70.
</p>
<p>
The problem for the computer is that it does not know what '65'
means when you tell it x = 65;. What you think of 65, it might
think of as:
<pre>
00000000000000000000000001000001
</pre>
But, also, to the computer, the letter 'A' is represented as:
<pre>
00000000000000000000000001000001
</pre>
So, whenever you instruct the computer write(x+&quot;\n&quot;);,
it must have some ay of knowing that you want to see '65' and
not 'A'.
</p>
<p>
The computer can tell the difference between '65' and 'A' through
the use of data types. A data types simply says what type of data
is being stored y the memory location pointed to by a given variable.
Thus, each LPC variable has a variable type which guides conversions.
In the example given above, you would have had the following line
somewhere in the code <B>before</B> the lines shown above:
<pre>
int x;
</pre>
This one line tells the driver that whatever value x points to,
it will be used as the data type &quot;int&quot;, which is short
for integer, or whole number. So you have a basic introduction
into the reason why data types exist. They exist so the driver
can make sense of the 0's and 1's that the computer is storing
in memory.
</p>
<hr size="1">
<p><strong>The data types of LPC</strong></p>
<p>
All LPMud drivers have the following data types:
<pre>
void, status, int, string, object, int *, string *, object *, mixed *
</pre>
Many drivers, but not all have the following important data types
which are important to discuss:
<pre>
float, mapping, float *, mapping *
</pre>
And there are a few drivers with the following rarely used data
types which are not important to discuss:
<pre>
function, enum, struct, char
</pre>
</p>
<hr size="1">
<p><strong>Simple data types</strong></p>
<p>
This introductory textbook will deal with the data types void,
status, int, float, string, object, mand mixed. You can find out
about the more complex data types like mappings and arrays in
the intermediate textbook. This chapter deals with the two simplest
data types (from the point of view of the LPC coder), int and
string.
</p>
<p>
An int is any whole number. Thus 1, 42, -17, 0, -10000023 are
all type int.
</p>
<p>
A string is one or more alphanumeric characters. Thus &quot;a&quot;,
&quot;we are borg&quot;, &quot;42&quot;, &quot;This is a string&quot;
are all strings. Note that strings are always enclosed in &quot;&quot;
to allow the driver to distinguish between the int 42 and the
string &quot;42&quot; as well as to distinguish between variable
names (like x) and strings by the same names (like &quot;x&quot;).
</p>
<p>
When you use a variable in code, you must first let the driver
know what type of data to which that variable points. This process
is called <B>declaration</B>. You do this at the beginning of
the function or at the beginning of the object code (outside of
functions before all functions which use it). This is done by
placing the name of the data type before the name of the variable
like in the following example:
<pre>
void add_two_and_two() {
    int x;
    int y;

    x = 2;
    y = x + x;
}
</pre>

Now, this is a complete function. The name of the function is
add_two_and_two(). The function begins with the declaration of
an int variable named x followed by the declaration of an in variable
named y. So now, at this point, the driver now has two variables
which point to NULL values, and it expects what ever values end
up there to be of type int.
</p>
<p>
A note about the data types void and status:
<blockquote>
Void is a trivial data type which points to nothing. It is not
used with respect to variables, but instead with respect to functions.
You will come to understand this better later. For now, you need
only understand that it points to no value.
</blockquote>
<blockquote>
The data type status is a boolean data type. That is, it can only
have 1 or 0 as a value. This is often referred to as being true
or false.
</blockquote>
</p>
<hr size="1">
<p><strong>Chapter Summary</strong></p>
<p>
For variables, the driver needs to know how the 0's and 1's the computer stores
in memory get converted into the forms in which you intend them to be used.
The simplest LPC data types are void, status, int, and string. You do not user
variables of type void, but the data type does come into play with respect to
functions. In addition to being used for translation from one form to the next,
data types are used in determining what rules the driver uses for such operations
as +, -, etc. For example, in the expression 5+5, the driver knows to add the
values of 5 and 5 together to make 10. With strings however, the rules for int
addition make no sense. So instead, with &quot;a&quot;+&quot;b&quot;, it appends
&quot;b&quot; to the string &quot;a&quot; so that the final string is &quot;ab&quot;.
Errors can thus result if you mistakenly try to add &quot;5&quot;+5. Since int
addition makes no sense with strings, the driver will convert the second 5 to
&quot;5&quot; and use string addition. The final result would be &quot;55&quot;.
If you were looking for 10, you would therefore have ended up with erroneous
code. Keep in mind, however, that in most instances, the driver will not do
something so useful as coming up with &quot;55&quot;. It comes up with &quot;55&quot;
cause it has a rule for adding a string to an int, namely to treat the int as
a string. In most cases, if you use a data type for which an operation or function
is not defined (like if you tried to divide &quot;this is&quot; by &quot;nonsense&quot;,
&quot;this is&quot;/&quot;nonsense&quot;), the driver will barf and report an
error to you.
</p>