triggers.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 :: Creating Triggers
  8. </div>
  9. <!-- content starts here -->
  10. <div class="content-wrap"><div class="content-body-wrap"><div class="content">
  11. <div class="head">Triggers</div>
  12. <div class="info">
  13. The main means of in-game scripting is to attach triggers to mobiles,
  14. objects, and rooms. Triggers are scripts that execute when a pre-specified game
  15. event occurs. For instance, someone speaking, entering or leaving a room,
  16. dropping an object, and so forth. Like the things they attach to, triggers
  17. exist as game content within a zone. They have reference keys, just like
  18. all other game content. Effectively, they are behaviors that are part of the
  19. game world.
  20. <p></p>
  21. NakedMud comes with 14 built-in trigger types, which will each be covered in
  22. the next section. This section will explain how to bring up and use the trigger
  23. editor.
  24. </div>
  25. <div class="head">tedit</div>
  26. <div class="info">
  27. The command for editing a trigger is tedit. If a key is specified, that
  28. trigger's information is brought up in the online editing tool. If the key does
  29. not exist, a new trigger is created for that key.
  30. <pre class="mud">
  31. > <font class="cmd">tedit helloworld</font>
  32. [helloworld@tutorial]
  33. 1) Name : An Unfinished Trigger
  34. 2) Trigger type: &lt;NONE&gt;
  35. 3) Script Code
  36. # trigger code goes here
  37. # make sure to comment it with pounds (#)
  38. Enter choice, ? [topic] for help, or Q to quit:
  39. </pre>
  40. Every trigger must be given a type. This is the game event that causes
  41. the trigger to run. Each type of trigger can only be attached to certain
  42. game contents. When a trigger type is listed, what it can be attached to
  43. will also display. Let's create a speech trigger as a first example:
  44. <pre class="mud">
  45. Enter choice, ? [topic] for help, or Q to quit: <font class="cmd">2</font>
  46. Type Usable By
  47. -----------------------------------
  48. 0) speech mob, room
  49. 1) greet mob
  50. 2) enter mob, room
  51. 3) exit mob, room
  52. 4) move mob
  53. 5) drop obj, room
  54. 6) get obj, room
  55. 7) give obj, mob
  56. 8) receive mob
  57. 9) wear mob
  58. 10) remove obj, mob
  59. 11) reset room
  60. 12) combat mob
  61. 14) open obj, room
  62. Enter a trigger type: <font class="cmd">0</font>
  63. [helloworld@tutorial]
  64. 1) Name : An Unfinished Trigger
  65. 2) Trigger type: <font class="highlight">speech</font>
  66. 3) Script Code
  67. # trigger code goes here
  68. # make sure to comment it with pounds (#)
  69. Enter choice, ? [topic] for help, or Q to quit:
  70. </pre>
  71. Now let's set it up to be a room trigger; every time a person says
  72. hello world!, teleport them to a new room:
  73. <pre class="mud">
  74. [helloworld@tutorial]
  75. 1) Name : <font class="highlight">Teleport the person to a new zone</font>
  76. 2) Trigger type: speech
  77. 3) Script Code <font class="highlight">
  78. if arg.lower() == "hello world!":
  79. ch.room = "startroom@magic_forest"
  80. ch.send("You say the magic words, and suddenly find yourself in a new place.")
  81. ch.act("look")
  82. </font>
  83. Enter choice, ? [topic] for help, or Q to quit:
  84. </pre>
  85. When this trigger is attached to a room, every time a person in it says the
  86. magic words they will be teleported to another room.
  87. </div>
  88. <!-- content ends here-->
  89. </div></div></div>
  90. <!-- navigation starts here -->
  91. <div class="nav-wrap"><div class="nav">
  92. <iframe src="nav.html" height="100%" width="100%" scrolling=no frameborder=0>
  93. </iframe>
  94. <!-- navigation ends here -->
  95. </div></div>
  96. <!--div class="footer">Edit Date: Nov 15, 2008. By Geoff Hollis</div-->
  97. </body>
  98. </html>