The Basics


LPC is an object oriented language much similar to the programming language C. Constructs and types are almost identical to C. You use {} to signify a program block, use the same variable types and so forth. This course will rely on you knowing the basics of the C language. If not, get a crashcourse for C, and then proceed with this course. This is not a general course on LPC, either, so it could be a good idea to download some LPC courses from the net. Just search the web and you'll probably come across several. This course is aimed at showing how objects are created with the Icewind Mudlib (derived from the Vikings Mudlib).

Suggested reading: /doc/syntax/*
                   /doc/lpc/*

Everything inside the MUD is an object with functions/variables attached to it. Commands, items, monsters, bulletin boards are all objects inside the MUD world. But, they contain different functions, of course. For instance a drink will have to contain drinking functions, while a weapon will have to contain functions related to combat. But, how do you know what kind of functions to add to a weapon or an item? Luckily, most of the functions you will ever need has already been written. For instance, if you take a look in the /std directory of the MUD you will find a lot of standard files related to different objects inside the MUD world. object.c is the file containing the basic functions to all objects. weapon.c contains all the functions for weapons. But, as you can see, a weapon is an object, isn't it? So instead of including all the functions needed for an object inside the weapon.c file, you inherit the object.c file and thereby giving the weapon all the standard functions for an object. If you know anything about C++ or other OO-languages, you will understand this easier. So, when we want to make for instance a monster, we inherit the /std/monster.c file, and thereby may use all the standard functions for a monster. Easy, isn't it? You will learn more about this in the first course.

If you take a quick stroll through the mudlib directories, you will at least find these directories:

Mudlib directories
Directory What's in there
/std Where all the standard object files are located.
/obj Where some more specific object files are located(bag, torch, etc)
/doc Documentation you should read.
/log Different logfiles. Don't cheat or we'll know it! ;-)
/pub Public files.
/players The players' own home directories.

The most important dirs for you right now are the /doc and /std dirs.

When you start coding, there are several commands you should be familiar with:

Important commands
Command Use
fresh Destroy a certain object and reload it. Use this command to check your files and load them into memory.
reset Reset an object.
clone Clone an object and move it to the cloner if possible.
goto Usually used to go into a file, usually a room.
home Goto your workroom.
dest Destroy a certain object and take it out of the mud.
loaddir Load an entire dir. Useful for checking several files at the same time.
updir Destroy an entire dir. Useful for clearing up objects you have been working on so that they don't take up valuable memory.
I Check to see what you're carrying and their pathnames.

You should also read the help for these commands before using them. Note the difference between the fresh command and the reset command. The fresh will reload the object, while the reset command will only cause reset() to be called in the object.
If you want to fresh/reset/dest a room you're inside, you may use '.' or 'env' as an argument.

Examples: 'reset .' 
          'fresh env'

To find help about something you have four choices. The first one is the easiest, ask someone for help. But, before doing so, you should attempt to gain the information on your own. If it's a command or some general information you're after, you can use the help command. 'help <subject>' should give you some help. You may also try 'help help' for a start. If you want help on coding issues, for instance which functions does a monster consist of, you should read the manual pages. These can be read with the man command. 'man monster' will give you some information about how to code monsters. But, these manual pages are not complete, far from it. So, if you're looking for something and it's not inside the man page, either ask someone else for help (a QC arch would be a good place to start; use 'help arches' to find out who's a QC arch) or you may look through the standard files themselves. Change your dir to the std dir('cd /std'), then do a 'ls' to get a listing of all the files in that dir. If for instance you're looking for a monster function, you can do a 'more monster.c' and go through the entire monster.c file. But, it's a lot to go through and the coding may be a bit hard to understand so it's not recommended for beginners.


WRITTEN: 30 - Sep - 1996 - Gunner
LAST UPDATE: 26 - May - 1998 - Gunner
HTML Version: 26 - Jan - 2000 - Ghorwin

[to the top] [table of contents]