MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | Intermediate LPC |
| 2 | Descartes of Borg |
| 3 | Novermber 1993 |
| 4 | |
| 5 | Chapter 1: Introduction |
| 6 | |
| 7 | 1.1 LPC Basics |
| 8 | Anyone reading this textbook should either have read the textbook LPC |
| 9 | Basics or be familiar enough with mud realm coding such that not only are |
| 10 | they capable of building rooms and other such objects involved in area |
| 11 | coding, but they also have a good idea of what is going on when the code |
| 12 | they write is executing. If you do not feel you are at this point, then go |
| 13 | back and read LPC Basics before continuing. If you do so, you will find |
| 14 | that what you read here will be much more meaningful to you. |
| 15 | |
| 16 | 1.2 Goals of This Textbook |
| 17 | The introductory textbook was meant to take people new to LPC from |
| 18 | knowing nothing to being able to code a nice realm on any LPMud. There |
| 19 | is naturally much more to LPC and to LPMud building, however, than |
| 20 | building rooms, armours, monsters, and weapons. As you get into more |
| 21 | complicated concepts like guilds, or desire to do more involved things with |
| 22 | your realm, you will find the concepts detailed in LPC Basics to be lacking |
| 23 | in support for these projects. Intermediate LPC is designed to take you |
| 24 | beyond the simple realm building process into a full knowledge of LPC for |
| 25 | functioning as a realm builder on an LPMud. The task of mudlib building |
| 26 | itself is left to a later text. After reading this textbook and working through |
| 27 | it by experimenting with actual code, the reader should be able to code game |
| 28 | objects to fit any design or idea they have in mind, so long as I have been |
| 29 | successful. |
| 30 | |
| 31 | 1.3 An Overview |
| 32 | What more is there? Well many of you are quite aware that LPC supports |
| 33 | mappings and arrays and have been asking me why those were not detailed |
| 34 | in LPC Basics. I felt that those concepts were beyond the scope of what I |
| 35 | was trying to do with that textbook and were more fitting to this textbook. |
| 36 | But new tools are all fine and dandy, what matters, however, is what you |
| 37 | can do with those tools. The goal of LPC Basics was to get you to building |
| 38 | quality LPMud realms. Mappings and arrays are not necessary to do that. |
| 39 | The goal of this book is to allow you to code any idea you might want to |
| 40 | code in your area. That ability requires the knowledge of mappings and |
| 41 | arrays. |
| 42 | |
| 43 | Any idea you want to code in an LPMud is possible. LPC is a language |
| 44 | which is amazingly well suited to this task. All that prevents you from |
| 45 | coding your ideas is your knowledge of LPC or an inadequate mudlib or |
| 46 | your mudÕs theme or administrative policies. This textbook cannot make |
| 47 | the mudlib you are working with any better, and it cannot change the mud |
| 48 | theme or the mudÕs administrative policies. Never once think that LPC is |
| 49 | incapable of doing what you want to do. If your idea is prevented by |
| 50 | administrative policies or themes, then it is simply not an idea for your |
| 51 | current mud. If the mudlib is inadequate, talk to the people in charge of |
| 52 | your mudlib about what can be done at the mudlib level to facilitate it. You |
| 53 | would be surprised by what is actually in the mudlib you did not know |
| 54 | about. More important, after reading this textbook, you should be able to |
| 55 | read all of the mudlib code in your mudÕs mudlib and understand what is |
| 56 | going on at each line in the mudlib code. You may not as yet be able to |
| 57 | reproduce that code on your own, but at least you can understand what is |
| 58 | going on at the mudlib level. |
| 59 | |
| 60 | This textbook starts out with a discussion about what the LPMud driver is |
| 61 | doing. One nice thing about this textbook, in general it is completely driver |
| 62 | and mudlib independent (excepting for the Dworkin Game Driver). The |
| 63 | chapter on the game driver does not get into actual implementation, but |
| 64 | instead deals with what all game drivers basically do in order to run the |
| 65 | mud. |
| 66 | |
| 67 | Next I discuss those magic topics everyone wants to know more about, |
| 68 | arrays and mappings. Mappings may be simultaneously the easiest and |
| 69 | most difficult data type to understand. Since they are sort of complex arrays |
| 70 | in a loose sense, you really need to understand arrays before discussing |
| 71 | them. All the same, once you understand them, they are much easier than |
| 72 | arrays to use in real situations. At any rate, spend most of your time |
| 73 | working with that chapter, because it is probably the most difficult, yet most |
| 74 | useful chapter in the book. |
| 75 | |
| 76 | After that follows a brief chapter on the LPC pre-compiler, a tool you can |
| 77 | use for sorting out how your code will look before it gets sent to the |
| 78 | compiler. Despite my horrid intro to it here, this chapter is perhaps the |
| 79 | easiest chapter in the textbook. I put it after the mappings and arrays |
| 80 | chapter for exactly that reason. |
| 81 | |
| 82 | Strings are re-introduced next, going into more detail with how you can do |
| 83 | such things as advanced command handling by breaking up strings. Once |
| 84 | you understand arrays fairly well, this chapter should be really simple. |
| 85 | |
| 86 | The next chapter is the second most important in the book. It may be the |
| 87 | most important if you ever intend to go beyond the intermediate stage and |
| 88 | dive into mudlib coding. That chapter involves the complex ideas behind |
| 89 | LPC inheritance. Since the goal of this textbook is not to teach mudlib |
| 90 | programming, the chapter is not a detailed discussion on object oriented |
| 91 | programming. Understanding this chapter, however, will give you some |
| 92 | good insights into what is involved with object oriented programming, as |
| 93 | well as allow you to build more complex objects by overriding functions |
| 94 | and defining your own base classes. |
| 95 | |
| 96 | Finally, the textbook ends with a simple discussion of code debugging. |
| 97 | This is not an essential chapter, but instead it is meant as more of an |
| 98 | auxiliary supplement to what the knowledge you have accumulated so far. |
| 99 | |
| 100 | 1.4 Not Appearing in This Textbook |
| 101 | Perhaps what might appear to some as the most glaring omission of this |
| 102 | textbook is largely a political omission, shadows. Never have I ever |
| 103 | encountered an example of where a shadow was either the best or most |
| 104 | effecient manner of doing anything. It does not follow from that, however, |
| 105 | that there are no uses for shadows. My reasoning for omitting shadows |
| 106 | from this textbook is that the learner is best served by learning the concepts |
| 107 | in this textbook first and having spent time with them before dealing with |
| 108 | the subject of shadows. In that way, I feel the person learning LPC will be |
| 109 | better capable of judging the merits of using a shadow down the road. I |
| 110 | will discuss shadows in a future textbook. |
| 111 | |
| 112 | If you are someone who uses shadows some or a lot, please do not take the |
| 113 | above paragraph as a personal attack. There may be some perfectly valid |
| 114 | uses for shadows somewhere which I have yet to encounter. Nevertheless, |
| 115 | they are not the ideal way to accomplish any given task, and therefore they |
| 116 | are not considered for the purposes of this textbook an intermediate coding |
| 117 | tool. |
| 118 | |
| 119 | I have also omitted discussions of security and object oriented |
| 120 | programming. Both are quite obviously mudlib issues. Many people, |
| 121 | however, might take exception with my leaving out a discussion of object |
| 122 | oriented programming. I chose to leave that for a later text, since most area |
| 123 | builders code for the creativity, not for the computer science theory. In both |
| 124 | the intermediate and beginner textbooks, I have chosen only to discuss |
| 125 | theory where it is directly applicable to practical LPC programming. For |
| 126 | people who are starting out green in LPC and want to code the next great |
| 127 | mudlib, perhaps theory would be more useful. But for the purposes of this |
| 128 | book, a discussion of object oriented programming is simply a snoozer. I |
| 129 | do plan to get heavy into theory with the next textbook. |
| 130 | |
| 131 | 1.5 Summary |
| 132 | LPC is not difficult to learn. It is a language which, although pathetic |
| 133 | compared to any other language for performing most computer language |
| 134 | tasks, is incredibly powerful and unequalled for the tasks of building an |
| 135 | area in MUD type games. For the beginner, it allows you to easily jump in |
| 136 | and code useful objects without even knowing what you are doing. For the |
| 137 | intermediate person, it allows you to turn any idea you have into textual |
| 138 | virtual reality. And for the advanced person, itÕs object oriented features |
| 139 | can allow you to build one of the most popular games on the internet. What |
| 140 | you can do is simply limited by how much you know. And learning more |
| 141 | does not require a computer science degree. |
| 142 | |
| 143 | Copyright (c) George Reese 1993 |