Advertisement
Guest User

ralphmerridew

a guest
Sep 15th, 2010
166
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Version 3 of Simple Chat by Mark Tilford begins here.
  2.  
  3. Use Default Allow Exiting Conversations translates as (- Constant AllowingExit 1; -).
  4. Use Default Forbid Exiting Conversations translates as (- Constant AllowingExit 0; -).
  5.  
  6.  
  7. Conversation exiting is a kind of value.
  8. The conversation exitings are player may exit upon zero, player may not exit.
  9. Current exiting is a conversation exiting that varies.
  10.  
  11. To allow exiting on zero: Now current exiting is player may exit upon zero.
  12. To forbid exiting on zero: Now current exiting is player may not exit.
  13.  
  14. To decide whether exiting on zero is allowed:
  15. if current exiting is player may exit upon zero, decide yes;
  16. decide no.
  17.  
  18. Chat node is a kind of value.
  19. The chat nodes are no quip chosen.
  20.  
  21. Table of Current Choices
  22. Result
  23. a chat node
  24. with 9 blank rows
  25.  
  26. The rowcount is a number which varies.
  27.  
  28. Finding responses to is an action applying to a chat node.
  29. Carry out finding responses to: do nothing.
  30.  
  31. Activatedness is a kind of value. The activatednesses are quip on.
  32. Activation relates various chat nodes to various activatednesses.
  33. The verb to activate (it activates, they activate, it activated) implies the activation relation.
  34.  
  35. To activate (which - a chat node): now which activates quip on.
  36. To deactivate (which - a chat node): now which does not activate quip on.
  37. To decide whether (which - a chat node) is sc-active:
  38. if which activates quip on, decide yes;
  39. decide no.
  40.  
  41. To link to (response - a chat node):
  42. if response is sc-active begin;
  43. increase rowcount by 1;
  44. [if rowcount is less than or equal to the number of rows in table of current choices begin;]
  45. if rowcount <= the number of rows in table of current choices begin;
  46. change result in row rowcount of table of current choices to response;
  47. otherwise;
  48. decrease rowcount by 1;
  49. end if;
  50. end if.
  51.  
  52.  
  53. To reset the links:
  54. repeat through the Table of Current Choices begin;
  55. blank out the whole row;
  56. end repeat;
  57. change rowcount to 0.
  58.  
  59. first chat node is a chat node that varies.
  60. second chat node is a chat node that varies. [I can't figure out how to make "giving link to it from" work using arguments, so I'm currently using globals. ]
  61. Giving text for is an action applying to a chat node.
  62. [Carry out] Report giving text for: say "Error: no text for [chat node understood].".
  63. Giving link to is an action applying to a chat node. [Carry out giving link to: say "Error: no link text for [chat node understood].".]
  64. Report giving link to: say "Error: no link text for [chat node understood].". [*** This line is incorrectly listed as the problem ***]
  65. [Giving link to it from is an action applying to two chat nodes. ]
  66. [Carry out giving link to it from: try giving link to second chat node understood.]
  67. [Carry out giving link to (tail - a chat node) from (head - a chat node): try giving link to head.]
  68. [Before giving link to (next - a chat node) from (prev - a chat node): change first chat node to next; change second chat node to prev.] [ *** This line is the real problem ***]
  69. [Carry out giving link to it from: try giving link to first chat node.]
  70.  
  71. Preparing is an action applying to a chat node.
  72. Carry out preparing: [say "preparing [chat node understood]"; activate the chat node understood.] [say "preparing [first chat node]";] activate first chat node.
  73.  
  74. [Instead of]Report giving text for no quip chosen: do nothing instead.
  75.  
  76. Include (-
  77. [ ReadChoice low high i;
  78. for (::) {
  79. print ">> ";
  80. KeyboardPrimitive (buffer, parse);
  81. i = TryNumber (1);
  82. if (i >= low && i <= high) return i;
  83. }
  84. ];
  85. -).
  86.  
  87.  
  88. To run a conversation from (current node - a chat node):
  89. let previous node be no quip chosen;
  90. let next node be no quip chosen;
  91. while current node is not no quip chosen begin;
  92. if using the default forbid exiting conversations option begin;
  93. forbid exiting on zero;
  94. otherwise;
  95. allow exiting on zero;
  96. end if;
  97. []
  98. try giving text for current node;
  99. reset the links;
  100. []
  101. try silently finding responses to current node;
  102. if rowcount is greater than 0 begin;
  103. repeat with current row running from 1 to rowcount begin;
  104. say "[current row]) [run paragraph on]";
  105. change next node to result in row current row of table of current choices;
  106. change first chat node to next node; [*** FIX: globals ***]
  107. change second chat node to current node; [*** FIX: globals ***]
  108. [try giving link to next node from current node;]
  109. [say " a ";]
  110. try giving link to next node;
  111. [say " b ";]
  112. end repeat;
  113. let choice made be 0;
  114. ;
  115. if exiting on zero is allowed begin;
  116. say "(or 0 to say nothing)";
  117. change choice made to the choice made from 0 to rowcount;
  118. otherwise;
  119. change choice made to the choice made from 1 to rowcount;
  120. end if;
  121. ;
  122. if choice made is 0 begin;
  123. change next node to no quip chosen;
  124. otherwise;
  125. change next node to result in row choice made of table of current choices;
  126. end if;
  127. [change first chat node to next node; [*** FIX: globals ***]
  128. change second chat node to current node; [*** FIX: globals ***]
  129. if next node is not no quip chosen,
  130. try giving link to next node from current node;]
  131. change previous node to current node;
  132. change current node to next node;
  133. otherwise;
  134. change current node to no quip chosen;
  135. end if;
  136. end while;
  137. [say "You walk away.".]
  138.  
  139. To decide what number is the choice made from (low value - a number) to (high value - a number): (- ReadChoice ( {low value}, {high value} ) -).
  140.  
  141. When play begins (this is the simplechat preparation rule):
  142. let current node be the chat node after no quip chosen;
  143. while current node is not no quip chosen begin;
  144. [say "prepreparing [current node]";]
  145. [activate current node;]
  146. change first chat node to current node; [*** FIX: globals ***]
  147. try preparing current node;
  148. change current node to the chat node after current node;
  149. end while.
  150.  
  151. [(If you want that text to vary depending on the previous chat node, you may instead use "Instead of giving link to ___ from ___:".)] [[Not supported by I7 at present]]
  152.  
  153. Simple Chat ends here.
  154.  
  155. ---- DOCUMENTATION ----
  156.  
  157. This is an extension to handle simple menu-based conversations.
  158.  
  159. For each thing the player can say, define a chat node value. To keep things organized, consider starting the name of each node with the name of the character the player is talking with, or something else related to the overall conversation.
  160.  
  161. For all chat nodes, you must put in an "Instead of giving text for ___: ..." override. This function is to display the text for when the player is at that chat node.
  162.  
  163. For all chat nodes which are linked from some other chat node (which will generally be all those which are not ones which start conversations), you must put in an "Report giving link to ___: ... instead;" override. This function is to display the text which will be listed in the menu. If you want the text to vary depending on the previous chat node, you may instead use "Report giving link to ___ when second chat node is ___:" Only chat nodes which are currently activated will be listed; the simplechat preparation rule will call the preparing action on all chat nodes; this activates the chat node by default. To change this, override the preparing action for that chat node, or replace the simplechat preparation rule.
  164.  
  165. For all chat nodes which are to display a menu, you must put in a "Carry out finding responses to ___:" override. For each chat node the player can go to from here, put in "link to ___;". If no chat nodes are linked to, then the conversation will stop.
  166.  
  167. If the list of options is to vary, this can be done by either putting conditionals in the "find responses to" action, or by activating / deactivating chat nodes.
  168.  
  169. For example, to make a chat option which only appears when the player has been to a certain room:
  170. 1) Put code like "if ____ is visited, link to ____;" into the "find responses to" action.
  171. 2) Initially deactivate the option with "Carry out preparing ____: instead do nothing." Activate it at the appropriate point with "After going to ___: activate ____; continue the action."
  172.  
  173. Finally, to show the menu, put in "run a conversation from ___".
  174.  
  175. There can be at most ten links printed from any chat node. Any more will be silently dropped. This number can be increased by adding rows to the Table Of Current Choices.
  176.  
  177. By default, the player can get out of any menu by choosing 0. To change this for all menus, put "Use Default Forbid Exiting Conversations;" at the beginning of the file. To change this for some menus, put "allow exiting on zero;" or "forbid exiting on zero;" in the appropriate "give text for ..." or "find responses to ..." block.
  178.  
  179. Example: * Chat Test - Have a conversation with Larry
  180.  
  181. *: "Chat Test" by Mark Tilford
  182.  
  183. Include Simple Chat by Mark Tilford.
  184.  
  185. Talking to is an action applying to one visible thing.
  186. Understand "talk to [someone]" as talking to. Report talking to: say "You have nothing to say.".
  187.  
  188. Conversation target is a person that varies.
  189. To converse with (target - a person) on (subject - a chat node):
  190. now conversation target is target;
  191. run a conversation from subject;
  192. now conversation target is nothing;
  193.  
  194.  
  195. Living Room is a room. East of the living room is the Family Room. Kitchen is west of the living room.
  196.  
  197. hello larry, hows tricks, good bye are chat nodes.
  198.  
  199. Report giving text for hello larry: instead say "Larry looks up as you approach him.".
  200. Carry out finding responses to hello larry: link to hows tricks; link to good bye; forbid exiting on zero.
  201.  
  202. Report giving link to hows tricks: say "'How's tricks?' " instead.
  203. Report giving text for hows tricks: deactivate hows tricks; say "'Just fine.'" instead.
  204. Carry out finding responses to hows tricks: link to good bye; forbid exiting on zero; stop the action.
  205.  
  206. Report giving link to good bye: instead say "'Good bye.' ".
  207. Report giving link to good bye when second chat node is hows tricks: instead say "'Well then, good bye.' ".
  208. Report giving text for good bye: instead say "'You too.'".
  209.  
  210. Larry is a man. Larry is in the living room.
  211.  
  212. Instead of talking to larry: run a conversation from hello larry.
  213.  
  214. sandra hello, sandra name, sandra job, sandra bye, sandra family, sandra kitchen are chat nodes.
  215.  
  216.  
  217. Report giving link to sandra bye: instead say "(Walk away) ".
  218. Report giving text for sandra bye: instead say "You nod and move the other direction.".
  219.  
  220. Carry out finding responses to while conversation target is sandra:
  221. if the chat node understood is not sandra bye begin;
  222. link to sandra name; link to sandra job; if kitchen is visited, link to sandra kitchen; link to sandra family; link to sandra bye; forbid exiting on zero;
  223. end if;
  224.  
  225. Report giving text for sandra hello: instead say "The woman looks up as you approach."
  226.  
  227. Report giving link to sandra name: say "'Who are you? '" instead.
  228. Report giving text for sandra name: deactivate sandra name; activate sandra job; say "'I'm Sandra.'" instead.
  229.  
  230. Report giving link to sandra job: instead say "'What do you do here?' ".
  231. Report giving text for sandra job: deactivate sandra job; instead say "'I'm the official greeter.'".
  232. Carry out preparing sandra job: instead do nothing.
  233.  
  234. Report giving link to sandra kitchen: instead say "'What do you think of the kitchen?' ".
  235. Report giving text for sandra kitchen: instead say "'It's an ordinary kitchen.'".
  236.  
  237. Report giving link to sandra family: say "'What do you think of the family room?' " instead.
  238. Report giving text for sandra family: say "'It's an ordinary family room.'" instead.
  239. Carry out preparing sandra family: instead do nothing.
  240.  
  241. After going to the family room: activate sandra family; continue the action.
  242.  
  243. Sandra is a woman. Sandra is in the living room.
  244. Instead of talking to sandra: converse with sandra on sandra hello.
  245.  
  246. John is a man. John is in the living room.
  247. john hello, john weather, john sports, john politics are chat nodes.
  248.  
  249. Instead of talking to john: run a conversation from john hello.
  250.  
  251. Report giving text for john hello: instead say "'Hi, I'm John. What shall we talk about?'".
  252. Carry out finding responses to john hello: link to john weather; link to john sports; link to john politics; stop the action.
  253.  
  254. Report giving link to john weather: say "The weather" instead.
  255. Report giving text for john weather: instead say "'Nice day,' says John, 'but a little cloudy.'".
  256.  
  257. Report giving link to john sports: say "Sports" instead.
  258. Report giving text for john sports: say "John yammers on about football." instead.
  259.  
  260. Report giving link to john politics: say "Politics" instead.
  261. Report giving text for john politics: say "John gabs about the mayor briefly." instead.
  262.  
  263. The macguffin is in the living room.
  264. The Baron CD is held by Victor. The description is "It's a copy of The Baron (Special Edition)."
  265. The Fate CD is held by Victor. The description is "It's a copy of Fate (Special Edition)."
  266.  
  267. Victor is a man. Victor is in the living room.
  268.  
  269. victor hello, victor given macguffin, victor reward, victor give baron, victor give fate, victor welcome are chat nodes.
  270.  
  271. Instead of talking to victor: run a conversation from victor hello.
  272.  
  273. Report giving text for victor hello:
  274. if the macguffin is held by Victor begin;
  275. say "'Thank you for the Macguffin.'";
  276. otherwise;
  277. say "'I'm really looking for a Macguffin. Any one will do.'";
  278. end if;
  279. stop the action.
  280.  
  281. Carry out finding responses to victor hello: if the macguffin is held by the player, link to victor given macguffin.
  282.  
  283. Report giving link to victor given macguffin: instead say "'Take this one.' (Give macguffin)".
  284. Report giving text for victor given macguffin: now the macguffin is held by victor; say "'That's perfect. You can have a special edition of either of my games.'" instead.
  285. Carry out finding responses to victor given macguffin: forbid exiting on zero; link to victor give baron; link to victor give fate.
  286.  
  287. Report giving link to victor give baron: instead say "'I'd like 'The Baron'.' ".
  288.  
  289. Report giving text for victor give baron: say "He hands you the CD. 'And thank you.'"; now the baron cd is held by the player; stop the action.
  290.  
  291. Carry out finding responses to victor give baron: forbid exiting on zero; link to victor welcome.
  292.  
  293. Report giving link to victor give fate: instead say "'I'd like 'Fate'.' ".
  294.  
  295. Report giving text for victor give fate: say "'Here you go, and thanks.'"; now the fate cd is held by the player; stop the action.
  296.  
  297. Carry out finding responses to victor give fate: forbid exiting on zero; link to victor welcome.
  298.  
  299. Report giving link to victor welcome: say "'You're welcome.' " instead.
  300.  
  301. Report giving text for victor welcome: say "Victor nods as you walk away." instead.
  302.  
  303. Instead of giving the macguffin to victor: say "You approach him."; try talking to victor.
  304.  
  305. test me with "talk to larry".
Advertisement
RAW Paste Data Copied
Advertisement