Advertisement
Shadowolf3400

Table-Controlled Messages, v1, for Inform7

Aug 9th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. Version 1/130809 of Table-Controlled Messages by Shadow Wolf begins here.
  2.  
  3. Use authorial modesty.
  4.  
  5. To say perform/@ (ph - phrase): (- if (0==0) {ph} -).
  6. To say perform/@ (r - rule): consider r;
  7.  
  8. Cycle-type is a kind of value. The cycle-types are cycle-stopping, cycle-random, cycle-shuffled and cycle-circular.
  9.  
  10. Table of Meta-table Information
  11. meta-name meta-index meta-type meta-length
  12. a table name a number a cycle-type a number
  13. with 30 blank rows.
  14.  
  15. To adjust the index of (T - a table name):
  16. choose row with meta-name of T in the Table of Meta-table Information;
  17. if the meta-type entry is cycle-stopping, now the meta-index entry is the meta-length entry;
  18. otherwise now the meta-index entry is 1;
  19. if the meta-type entry is cycle-shuffled, sort T in random order.
  20.  
  21. To print row (N - a number) of (T - a table name):
  22. choose row N in T;
  23. if there is a message entry, say "[the message entry]";
  24.  
  25. To print the/-- next message in/from/of (T - a table name), cycling, stopping, randomly or in shuffled order:
  26. if there is no meta-name of T in the Table of Meta-table Information:
  27. choose a blank row in the Table of Meta-table Information;
  28. now the meta-name entry is T;
  29. now the meta-index entry is 1;
  30. now the meta-length entry is the number of rows in T;
  31. now the meta-type entry is cycle-stopping;
  32. if cycling, now the meta-type entry is cycle-circular;
  33. if randomly, now the meta-type entry is cycle-random;
  34. if in shuffled order:
  35. now the meta-type entry is cycle-shuffled;
  36. sort T in random order;
  37. choose row with meta-name of T in the Table of Meta-table Information;
  38. let the index be the meta-index entry;
  39. if the meta-type entry is cycle-random:
  40. while the index is the meta-index entry, let the index be a random number from 1 to the meta-length entry;
  41. now the meta-index entry is the index;
  42. otherwise:
  43. increment the meta-index entry;
  44. print row index of T;
  45. if the meta-index entry is greater than the meta-length entry:
  46. adjust the index of T;
  47.  
  48.  
  49. Table-Controlled Messages ends here.
  50.  
  51. ---- DOCUMENTATION ----
  52.  
  53. This extension provides behavior similar to List Control and List Controller by Eric Eve. The major difference is that it is unnecessary for the author to manually manage a meta-table or list controller objects. Instead there is a meta-table which is managed automatically.
  54.  
  55. A message table a single column called "message" containing texts. To allow entries to run code, we define a text substitution: "[perform the special callback rule]" will execute the rule. You can also use this with any phrase: "[perform now the ball is green]". For brevity, you can use "@" instead of "perform": "[@ now the ball is green]".
  56.  
  57. The key phrase to use this table is "Print the next message in (table name)". You may specify one of four options: stopping, cycling, randomly, or in shuffled order. Stopping is the default, and indicates printing each message in order, and then repeating the last message when the end of the table is reached. Cycling will return to the first message when the end of the table is reached. Randomly will pick messages from the table at random, but no message will be repeated twice in a row. In shuffled order indicates that the table will be shuffled, the messages will be printed in the shuffled order, and when the last message is printed, the table will be shuffled again.
  58.  
  59. The behavior of a given message table is determined the *first* time the "Print the next message" phrase is called. After that, the phrase option is ignored (for that particular table).
  60.  
  61. If you have more than 30 message tables, you will need to extend the Table of Meta-table Information:
  62.  
  63. Table of Meta-table Information (continued)
  64. meta-name
  65. with 100 blank rows.
  66.  
  67. A simple example:
  68.  
  69. Include Table-Controlled Messages by Shadow Wolf.
  70.  
  71. Testing is a room.
  72.  
  73. Table of Jumping Messages
  74. message
  75. "You jump, but nothing happens."
  76. "You jump, and get a little dizzy."
  77. "You jump, but fail to set a new world record."
  78. "You jump, and a genie appears. Sadly, it disappears before you can do anything."
  79.  
  80. Instead of jumping: print the next message in the Table of Jumping Messages, in shuffled order; say "[paragraph break]".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement