content_scripts.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <html>
  2. <head>
  3. <link href="../tutorial.css" rel="stylesheet" type="text/css">
  4. </head>
  5. <body>
  6. <div class="header">
  7. The NakedMud Tutorial :: Content Scripts
  8. </div>
  9. <!-- content starts here -->
  10. <div class="content-wrap"><div class="content-body-wrap"><div class="content">
  11. <div class="head">mpedit, opedit, and rpedit</div>
  12. <div class="info">
  13. Just about everything in NakedMud is scriptable. In fact, the mere creation of
  14. a room, object, or mobile is just a script being run. Since scripts typically
  15. deal with rooms, objects, and mobiles, let's start by viewing a mobile's
  16. generation script. Create a mobile. Give it keywords, a name, a room
  17. description, and a regular description. Set its race and gender. Then enter the
  18. script editor for it:
  19. <pre class="mud">
  20. > <font class="cmd">mpedit enforcer@moonhaven</font>
  21. </pre>
  22. The 'p' stands for prototype. The scripts that generate game content are
  23. refered to as prototypes. When you use this command, you will see a few
  24. options to edit. Among them, will be a block of code that looks like this:
  25. <pre class="code">
  26. ### The following mproto was generated by medit
  27. ### If you edit this script, adhere to the stylistic
  28. ### conventions laid out by medit, or delete the top line
  29. ### keywords, short descs, room descs, and look descs
  30. me.keywords = "enforcer" + ", " + me.keywords
  31. me.name = "an enforcer"
  32. me.rdesc = "A Moonhaven enforcer is here, keeping the peace."
  33. me.desc = me.desc + " " + "He is a big brute of a man, with a thickset square
  34. jaw and big bushy eyebrows. A couple days of stubble covers his face, and he has
  35. a look about him that suggests he can't wait until you do something bad so he
  36. has an excuse to pound your face in with his mace."
  37. ### race and gender
  38. me.race = "human"
  39. me.gender = "male"
  40. </pre>
  41. Rooms, objects, and mobiles are generated by creating a blank slate copy, and
  42. then running a script over it to assign values. When a builder edits something,
  43. what they are actually doing is filling in the blanks for a script that will
  44. later be run.
  45. <p><p/>
  46. One thing to note here is that the mobile is referred to as 'me'. When a script
  47. is run over something, the thing it is being run over is always referred to as
  48. 'me', regardless of what it is. Other common script variables will be
  49. introduced later.
  50. <p><p/>
  51. A caveat also comes with this command. Every time OLC is opened, it must be
  52. able to properly parse the script that generates a piece of content. This means
  53. reliably knowing that its formatting rules are adhered to. If you do not know
  54. what those rules are, it is highly suggest you only use mpedit, opedit, and
  55. rpedit to view code, and never to edit it. Code can be appended to content
  56. prototypes through the OLC editor (every menu has an 'extra code' section that
  57. you can write in). If you have the need to add extra scripting to content, do
  58. it this way.
  59. </div>
  60. <!-- content ends here-->
  61. </div></div></div>
  62. <!-- navigation starts here -->
  63. <div class="nav-wrap"><div class="nav">
  64. <iframe src="nav.html" height="100%" width="100%" scrolling=no frameborder=0>
  65. </iframe>
  66. <!-- navigation ends here -->
  67. </div></div>
  68. <!--div class="footer">Edit Date: Nov 15, 2008. By Geoff Hollis</div-->
  69. </body>
  70. </html>