|
|
|||||
|
Ok, lets get to work...
Unfortunatly I'm not going to set you lose quite yet. I will not take a moment to discuss a few topics armout LPC. You should take some time in the near future and read Descarte's LPC tutorial books available here since they will explain LPC in more detail. Quite simply LPC is an object orientated language. That means everything you create is an object. For the most part each file you create will be an object as well. So each room will be a different file, and each monster and object will be a different file too. You should try and keep the following format of all your files: 1. comments 2. main function (usually create()) 3. other functionsMost of the files you will encounter will have that format. Let us look at your workroom file. You will end up editing this file to make a custom workroom for yourself. 1 // single line comment line 2 3 /* different type of comment 4 can go on many lines */ 5 6 // Petrarch 7 // Standard Workroom 8 9 #includeThat is a listing of what it looks like in ed with number mode on. There are additional comments added here so we can talk about them. Typically your files will begin with what is on line 6, a simple comment line which names you as the author. Ok, so lets talk about comments. When you see // that is the start of a comment. A // can be anywhere on a line, sometimes you will see it in the middle of a line. Bascilly this tells the MUD that everything after the // is a comment and to ignore the rest of the line, it is not code. The /* and */ type comments are different. These comments are ment for multiple lines. Basiclly /* is the start of a comment and */ is the end of the comment. Do not ever put a /* */ comment inside another /* */ comment. It can cause problems. Line 9 is of interest as well. This line includes a header file called std.h. Header files are used to define information. More info on header files is in problem set 6. Line 11 tells us that this file (this object) is a room, and we inherit all in information about rooms. Line 13 starts our main function, called create() and it ends on line 29. Functions are in the format of: type functionname(args) { ..... }
The rest of the file sets information. This information is what you will edit. Rooms are discussed in much more details in the room examples and many more features are shown in those. For now though use your skills from the previous problem set and edit your workroom. Once you are ready it is time to move on to the next problem set. Just a note, the numbers are not part of the code. Those numbers can be turned on and off with the n command in the editor. They are there to allow simple editing of the file. So when you edit lines don't type in those numbers. |
|||||
|