routine.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html><head><title>Python: routine</title>
  3. </head><body bgcolor="#f0f0f8">
  4. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
  5. <tr bgcolor="#7799ee">
  6. <td valign=bottom>&nbsp;<br>
  7. <font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>routine</strong></big></big></font></td
  8. ><td align=right valign=bottom
  9. ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/hollis/Desktop/nakedmud/lib/pymodules/routine.py">/Users/hollis/Desktop/nakedmud/lib/pymodules/routine.py</a></font></td></tr></table>
  10. <p><tt>routine.py<br>
  11. &nbsp;<br>
  12. This&nbsp;is&nbsp;a&nbsp;module&nbsp;for&nbsp;setting&nbsp;up&nbsp;one-time&nbsp;or&nbsp;repeatable&nbsp;routines&nbsp;for&nbsp;mobs.&nbsp;This<br>
  13. can&nbsp;include&nbsp;walking&nbsp;a&nbsp;path,&nbsp;forging&nbsp;a&nbsp;sword,&nbsp;singing&nbsp;verses&nbsp;of&nbsp;a&nbsp;song,&nbsp;or<br>
  14. anything&nbsp;else.&nbsp;This&nbsp;was&nbsp;primarily&nbsp;meant&nbsp;to&nbsp;be&nbsp;for&nbsp;path-following,&nbsp;but&nbsp;I&nbsp;figured<br>
  15. it&nbsp;was&nbsp;worth&nbsp;the&nbsp;time&nbsp;to&nbsp;generalize&nbsp;it&nbsp;out&nbsp;for&nbsp;more&nbsp;complex&nbsp;actions</tt></p>
  16. <p>
  17. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  18. <tr bgcolor="#aa55cc">
  19. <td colspan=3 valign=bottom>&nbsp;<br>
  20. <font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
  21. <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  22. <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="auxiliary.html">auxiliary</a><br>
  23. <a href="event.html">event</a><br>
  24. </td><td width="25%" valign=top><a href="mud.html">mud</a><br>
  25. <a href="mudsys.html">mudsys</a><br>
  26. </td><td width="25%" valign=top><a href="storage.html">storage</a><br>
  27. </td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
  28. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  29. <tr bgcolor="#ee77aa">
  30. <td colspan=3 valign=bottom>&nbsp;<br>
  31. <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
  32. <tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  33. <td width="100%"><dl>
  34. <dt><font face="helvetica, arial"><a href="routine.html#RoutineAuxData">RoutineAuxData</a>
  35. </font></dt></dl>
  36. <p>
  37. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  38. <tr bgcolor="#ffc8d8">
  39. <td colspan=3 valign=bottom>&nbsp;<br>
  40. <font color="#000000" face="helvetica, arial"><a name="RoutineAuxData">class <strong>RoutineAuxData</strong></a></font></td></tr>
  41. <tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
  42. <td colspan=2><tt>Holds&nbsp;character&nbsp;data&nbsp;related&nbsp;to&nbsp;character&nbsp;routines.<br>&nbsp;</tt></td></tr>
  43. <tr><td>&nbsp;</td>
  44. <td width="100%">Methods defined here:<br>
  45. <dl><dt><a name="RoutineAuxData-__init__"><strong>__init__</strong></a>(self, set<font color="#909090">=None</font>)</dt></dl>
  46. <dl><dt><a name="RoutineAuxData-copy"><strong>copy</strong></a>(self)</dt></dl>
  47. <dl><dt><a name="RoutineAuxData-copyTo"><strong>copyTo</strong></a>(self, to)</dt></dl>
  48. <dl><dt><a name="RoutineAuxData-read"><strong>read</strong></a>(self, set)</dt></dl>
  49. <dl><dt><a name="RoutineAuxData-store"><strong>store</strong></a>(self)</dt></dl>
  50. </td></tr></table></td></tr></table><p>
  51. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  52. <tr bgcolor="#eeaa77">
  53. <td colspan=3 valign=bottom>&nbsp;<br>
  54. <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
  55. <tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  56. <td width="100%"><dl><dt><a name="-cmd_routine"><strong>cmd_routine</strong></a>(ch, cmd, arg)</dt><dd><tt>Appends&nbsp;a&nbsp;routine&nbsp;onto&nbsp;a&nbsp;character.&nbsp;The&nbsp;second&nbsp;argument&nbsp;needs&nbsp;to&nbsp;be&nbsp;an<br>
  57. evaluable&nbsp;list&nbsp;statement.&nbsp;Put&nbsp;it&nbsp;in&nbsp;parentheses&nbsp;to&nbsp;avoid&nbsp;being&nbsp;cut&nbsp;off<br>
  58. as&nbsp;spaces,&nbsp;since&nbsp;parse&nbsp;treats&nbsp;it&nbsp;as&nbsp;a&nbsp;single&nbsp;word.&nbsp;Example:<br>
  59. &nbsp;<br>
  60. &nbsp;&nbsp;&gt;&nbsp;routine&nbsp;man&nbsp;"['say&nbsp;hi',&nbsp;(3,&nbsp;'say&nbsp;I&nbsp;am&nbsp;a&nbsp;little&nbsp;teapot')]"&nbsp;True<br>
  61. &nbsp;<br>
  62. this&nbsp;will&nbsp;say&nbsp;hi&nbsp;after&nbsp;the&nbsp;default&nbsp;delay,&nbsp;and&nbsp;I&nbsp;am&nbsp;a&nbsp;little&nbsp;teapot&nbsp;after<br>
  63. a&nbsp;delay&nbsp;of&nbsp;3.&nbsp;It&nbsp;will&nbsp;then&nbsp;loop&nbsp;through&nbsp;this&nbsp;process&nbsp;indefinitely.<br>
  64. Alternatively,&nbsp;these&nbsp;commands&nbsp;can&nbsp;be&nbsp;replaced&nbsp;with&nbsp;function&nbsp;calls.</tt></dd></dl>
  65. <dl><dt><a name="-do_step"><strong>do_step</strong></a>(ch)</dt><dd><tt>Performs&nbsp;the&nbsp;current&nbsp;step&nbsp;increments</tt></dd></dl>
  66. <dl><dt><a name="-register_routine_check"><strong>register_routine_check</strong></a>(check)</dt><dd><tt>adds&nbsp;a&nbsp;routine&nbsp;check&nbsp;to&nbsp;the&nbsp;global&nbsp;list.&nbsp;Must&nbsp;be&nbsp;a&nbsp;function&nbsp;taking&nbsp;one<br>
  67. argument,&nbsp;which&nbsp;is&nbsp;the&nbsp;character&nbsp;doing&nbsp;the&nbsp;routine.&nbsp;Return&nbsp;should&nbsp;be<br>
  68. True&nbsp;if&nbsp;the&nbsp;check&nbsp;succeeded&nbsp;(i.e.,&nbsp;we&nbsp;should&nbsp;not&nbsp;do&nbsp;a&nbsp;routine)</tt></dd></dl>
  69. <dl><dt><a name="-routine_event"><strong>routine_event</strong></a>(owner, data, arg)</dt><dd><tt>this&nbsp;is&nbsp;the&nbsp;event&nbsp;that&nbsp;perpetuates&nbsp;NPC&nbsp;routines.&nbsp;Each&nbsp;NPC&nbsp;that&nbsp;has&nbsp;a<br>
  70. routine&nbsp;running&nbsp;has&nbsp;one&nbsp;of&nbsp;these&nbsp;events&nbsp;tied&nbsp;to&nbsp;him&nbsp;or&nbsp;her.&nbsp;When&nbsp;the<br>
  71. routine&nbsp;time&nbsp;expires,&nbsp;a&nbsp;check&nbsp;is&nbsp;made&nbsp;to&nbsp;see&nbsp;if&nbsp;the&nbsp;routine&nbsp;can&nbsp;go&nbsp;on.<br>
  72. If&nbsp;it&nbsp;can,&nbsp;the&nbsp;routine&nbsp;step&nbsp;is&nbsp;performed&nbsp;and&nbsp;the&nbsp;step&nbsp;number&nbsp;is<br>
  73. incremented</tt></dd></dl>
  74. <dl><dt><a name="-set_routine"><strong>set_routine</strong></a>(ch, routine, repeat<font color="#909090">=False</font>, checks<font color="#909090">=None</font>)</dt><dd><tt>Sets&nbsp;a&nbsp;routine&nbsp;to&nbsp;a&nbsp;character.&nbsp;Routine&nbsp;steps&nbsp;can&nbsp;constain&nbsp;commands<br>
  75. (character&nbsp;strings),&nbsp;functions&nbsp;(one&nbsp;argument,&nbsp;ch),&nbsp;or&nbsp;tuples<br>
  76. (delay,&nbsp;string&nbsp;|&nbsp;function).&nbsp;If&nbsp;a&nbsp;tuple&nbsp;is&nbsp;not&nbsp;supplied,&nbsp;the&nbsp;default<br>
  77. step&nbsp;time&nbsp;is&nbsp;used</tt></dd></dl>
  78. <dl><dt><a name="-start_routine"><strong>start_routine</strong></a>(ch)</dt><dd><tt>starts&nbsp;a&nbsp;character&nbsp;routine&nbsp;event&nbsp;in&nbsp;motion</tt></dd></dl>
  79. <dl><dt><a name="-try_step"><strong>try_step</strong></a>(ch)</dt><dd><tt>Checks&nbsp;to&nbsp;see&nbsp;if&nbsp;we&nbsp;can&nbsp;perform&nbsp;a&nbsp;step&nbsp;in&nbsp;the&nbsp;routine.&nbsp;Returns&nbsp;true&nbsp;or<br>
  80. false&nbsp;if&nbsp;it&nbsp;did&nbsp;or&nbsp;not</tt></dd></dl>
  81. </td></tr></table><p>
  82. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  83. <tr bgcolor="#55aa55">
  84. <td colspan=3 valign=bottom>&nbsp;<br>
  85. <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
  86. <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  87. <td width="100%"><strong>__dflt_routine_step_time__</strong> = 10<br>
  88. <strong>__global_routine_checks__</strong> = [&lt;function &lt;lambda&gt; at 0x105b170&gt;]</td></tr></table>
  89. </body></html>