Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.84 KB | None | 0 0
  1. #CLASS {LIBDB}
  2. //
  3. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. // The LIBDB variable will store pertinent library data not stored within the Database.
  5. // =======================================================================================================================
  6. //
  7. #VAR LIBDB ""
  8. #ADDKEY LIBDB vNums "" // ===== vNums of all Saved libraries
  9. #ADDKEY LIBDB Haven "" // ===== vNums of all Haven libraries
  10. #ADDKEY LIBDB Guild "" // ===== vNums of all Guild libraries
  11. #ADDKEY LIBDB Order "" // ===== vNums of all Order libraries
  12. #ADDKEY LIBDB City "" // ===== vNums of all Grand libraries
  13. #ADDKEY LIBDB Grand "" // ===== vNums of all City libraries
  14. #ADDKEY LIBDB Book "" // ===== (READ) Last read book (#)
  15. #ADDKEY LIBDB Page "" // ===== (READ) Last read page (#)
  16. #ADDKEY LIBDB bNum "" // ===== (CAPTURE) Book Number
  17. #ADDKEY LIBDB wSpace "" // ===== (CAPTURE) White Space
  18. #ADDKEY LIBDB bTitle "" // ===== (CAPTURE) Book Title
  19. #ADDKEY LIBDB Category "" // ===== (CAPTURE) Book Category
  20. #ADDKEY LIBDB vNum "" // ===== (CAPTURE) Aetolian vNum
  21. #ADDKEY LIBDB Compare "" // ===== Comparing Library to Library
  22. #ADDKEY LIBDB Update {0} // ===== Updating library On/Off flag
  23. #ADDKEY LIBDB temp_comp "" // ===== Used for temp lib comparison
  24. #ADDKEY LIBDB cat_add "" // ===== Sorting into Categories, INV
  25. //
  26. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. // Used for saving into categories from inventory, and moving books within a library.
  28. // =======================================================================================================================
  29. //
  30. #EVENT move_cat {
  31. #LOCAL $c
  32. $c=%find(%gmcp.room.info.num,All,vNum)
  33. #IF (%numitems($c)) {
  34. #LOCAL $a $b
  35. $a=%find(%gmcp.room.info.num,All,vNum)
  36. #FORALL $a {#ADDI $b %db(%i,Category)}
  37. $b=%replace($b,":"," >")
  38. #FORALL %pick("p:Select a category to move:",$b) {library move @LIBDB.cat_add %replace(%i," >",":")}
  39. } {
  40. #SAY {}
  41. #SAY {%ansi(13)There are no saved categories for this location.}
  42. #CR
  43. }
  44. }
  45. //
  46. #EVENT add_cat {
  47. #LOCAL $c
  48. $c=%find(%gmcp.room.info.num,All,vNum)
  49. #IF (%numitems($c)) {
  50. #LOCAL $a $b
  51. $a=%find(%gmcp.room.info.num,All,vNum)
  52. #FORALL $a {#ADDI $b %db(%i,Category)}
  53. $b=%replace($b,":"," >")
  54. #FORALL %pick("p:Select a category to add:",$b) {library add @LIBDB.cat_add %replace(%i," >",":")}
  55. } {
  56. #SAY {}
  57. #SAY {%ansi(13)There are no saved categories for this location.}
  58. #CR
  59. }
  60. }
  61. //
  62. #TRIGGER {^~"(%w)(%d)~"(%s)(*).$} {#IF (%1 = "book" OR %1 = "scroll" OR %1 = "journal" OR %1 = "omnibus") {#SUB {~"<send 'read %1%2|LIBDB.cat_add=%1%2;#RAISE add_cat' 'Read|Categorize'>%1%2</send>~"%3%4%5.}}}
  63. //
  64. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  65. // Various other aliases and triggers.
  66. // =======================================================================================================================
  67. //
  68. #TRIGGER {%e[35m} {#IF (%gmcp.room.info.details = library) {LIBDB.Category=%line}} "" {color}
  69. //
  70. #TRIGGER {A small sign indicates that LIBRARY CATALOG will list the materials in this library.} {#LOCAL $a;$a=%find(%gmcp.room.info.num,All,vNum);#IF (!%numitems($a)) {#MESS 1 "This library is not in the database."}}
  71. //
  72. #ALIAS read {#SWITCH (%begins(%lower(%1),n)) {LIBDB.Page=@LIBDB.Page+1;~read @LIBDB.Book page @LIBDB.Page} (%lower(%2) = page) {LIBDB.Book=%1;LIBDB.Page=%3;~read %params()} {LIBDB.Book=%1;LIBDB.Page=1;~read %1}}
  73. //
  74. #ALIAS temp_comp {#SWITCH (%begins(%1,a)) {#ADDI LIBDB.temp_comp %gmcp.room.info.num;LIBDB.Compare=@LIBDB.temp_comp} (%begins(%1,r)) {#DELI LIBDB.temp_comp %gmcp.room.info.num} (%begins(%1,c)) {LIBDB.temp_comp=""} {#SAY {};#SAY {%ansi(13)You have used an invalid parameter.};#SAY {%ansi(13)You may add, remove or clear the list.};#CR}}
  75. //
  76. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  77. // Searching the database.
  78. // =======================================================================================================================
  79. //
  80. #ALIAS SLIB {
  81. #DBLOAD LIB
  82. #LOCAL $r $f $s $l
  83. #IF (%begins(%lower(%1),a)) {$r=%find(%params(2),All,Author);$s=1;$f=a} {
  84. #IF (%begins(%lower(%1),t)) {$r=%find(%params(2),All,Title);$s=1;$f=t} {
  85. #IF (%begins(%lower(%1),c)) {$r=%find(%params(2),All,Category);$s=1;$f=c} {
  86. }}};
  87. #IF ($s) {
  88. #IF (%gmcp.room.info.details = library AND %numitems($r)) {
  89. #FORALL $r {
  90. #IF (%db(%i,vNum) != %gmcp.room.info.num) {#DELI $r %i}
  91. }
  92. }
  93. #IF (%numitems($r)) {
  94. #SAY {}
  95. #SWITCH ($f=a) {#SAY {%ansi(5)Books written by: %ansi(13)%params(2)}} ($f=t) {#SAY {%ansi(5)Titles containing: %ansi(13)%params(2)}} ($f=c) {#SAY {%ansi(5)Books in Category: %ansi(13)%params(2)}}
  96. #FORALL $r {
  97. #SWITCH (%ismember(%db(%i,vNum),@LIBDB.Haven)) {$l=H} (%ismember(%db(%i,vNum),@LIBDB.Order)) {$l=O} (%ismember(%db(%i,vNum),@LIBDB.Guild)) {$l=G} (%ismember(%db(%i,vNum),@LIBDB.Grand)) {$l=L} (%ismember(%db(%i,vNum),@LIBDB.City)) {$l=C} {$l=space}
  98. #MXP {%ansi(6) %if(%len(%db(%i,vNum)) = 1," ")%if(%len(%db(%i,vNum)) = 2," ")%if(%len(%db(%i,vNum)) = 3," ")%if(%len(%db(%i,vNum)) = 4," ")<send 'path find %db(%i,vNum);path go gallop'>v%db(%i,vNum)</send> %ansi(15)~: %ansi(6)%if(%len(%db(%i,bNum)) = 1," ")%if(%len(%db(%i,bNum)) = 2," ")%if(%len(%db(%i,bNum)) = 3," ")%if(%len(%db(%i,bNum)) = 4," ")%if(%len(%db(%i,bNum)) = 5," ")<send 'read %db(%i,bNum)|take 500 gold from pack;library copy %db(%i,bNum)|library remove %db(%i,bNum)|#RAISE show_db %i' 'Read|Copy|Remove|Details'>%db(%i,bNum)</send> %ansi(15)~: %ansi(2)%if($l=space," ",$l) %ansi(15)~: %ansi(3)%db(%i,Title) %ansi(7)by %ansi(3)%db(%i,Author)}
  99. }
  100. #CR
  101. } {
  102. #SAY {}
  103. #SAY {%ansi(13)There were no results for your query.}
  104. #CR
  105. }
  106. } {
  107. #SAY {}
  108. #SAY {%ansi(13)You have used an invalid search parameter.}
  109. #SAY {%ansi(13)You may search by author, title or category.}
  110. #CR
  111. }
  112. }
  113. //
  114. #EVENT show_db {
  115. #SAY {}
  116. #SAY {}
  117. #SHOWDB {%1}
  118. #CR
  119. }
  120. //
  121. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  122. // Updating and removing libraries from the database.
  123. // =======================================================================================================================
  124. //
  125. #ALIAS LIB {#DBLOAD LIB;#SWITCH (%begins(%lower(%1),c)) {LIBDB.temp_comp="";#SWITCH (%begins(%lower(%2),h)) {LIBDB.Compare=@LIBDB.Haven} (%begins(%lower(%2),g)) {LIBDB.Compare=@LIBDB.Guild} (%begins(%lower(%2),o)) {LIBDB.Compare=@LIBDB.Order} (%begins(%lower(%2),c)) {LIBDB.Compare=@LIBDB.City} (%begins(%lower(%2),l)) {LIBDB.Compare=@LIBDB.Grand} {#SAY {};#SAY {%ansi(13)You have used an invalid compare parameter.};#SAY {%ansi(13)You may compare to: Haven, Order, Guild, City or Library.};#CR}} (%begins(%lower(%1),a)) {#RAISE lib_add} (%begins(%lower(%1),r)) {#RAISE lib_rem %params(2)} (%begins(%lower(%1),u)) {#RAISE lib_upd} (%begins(%lower(%1),s)) {#IF (%gmcp.room.info.details = library) {#SWITCH (%begins(%lower(%2),h)) {#ADDI LIBDB.Haven %gmcp.room.info.num;#SAY {};#SAY {%ansi(13)Set As: Haven};#CR} (%begins(%lower(%2),o)) {#ADDI LIBDB.Order %gmcp.room.info.num;#SAY {};#SAY {%ansi(13)Set As: Order};#CR} (%begins(%lower(%2),g)) {#ADDI LIBDB.Guild %gmcp.room.info.num;#SAY {};#SAY {%ansi(13)Set As: Guild};#CR} (%begins(%lower(%2),c)) {#ADDI LIBDB.City %gmcp.room.info.num;#SAY {};#SAY {%ansi(13)Set As: City};#CR} (%begins(%lower(%2),l)) {#ADDI LIBDB.Grand %gmcp.room.info.num;#SAY {};#SAY {%ansi(13)Set As: Library};#CR} {#SAY {};#SAY {%ansi(13)You have used an invalid location parameter.};#SAY {%ansi(13)You may set: Haven, Order, Guild, City or Library.};#CR}} {#SAY {};#SAY {%ansi(13)This location is lot a library.};#CR}}}
  126. //
  127. #EVENT lib_add {
  128. LIBDB.Update=1
  129. #CALL %alarm(lib_add,4000)
  130. LIBDB.vNum=%gmcp.room.info.num
  131. library catalog
  132. }
  133. //
  134. #EVENT lib_rem {
  135. #LOCAL $a
  136. #IF (%1) {
  137. $a=%sort(%find(%1,All,vNum),1)
  138. #FORALL $a {#DBDELETE %i}
  139. } {
  140. LIBDB.vNum=%gmcp.room.info.num
  141. $a=%sort(%find(@LIBDB.vNum,All,vNum),1)
  142. #FORALL $a {#DBDELETE %i}
  143. }
  144. #DBSAVE
  145. }
  146. //
  147. #EVENT lib_upd {
  148. #LOCAL $a
  149. $a=%sort(%find(%gmcp.room.info.num,All,vNum),1)
  150. #FORALL $a {#DBDELETE %i}
  151. LIBDB.Update=1
  152. #CALL %alarm(lib_add,4000)
  153. LIBDB.vNum=%gmcp.room.info.num
  154. library catalog
  155. }
  156. //
  157. #ALARM "lib_add" {4} {LIBDB.Update=0;#DBSAVE}
  158. #SUS lib_add
  159. //
  160. #TRIGGER {^Type MORE to continue reading. ~(%d~% shown~)$} {#IF (@LIBDB.Update) {more;#CALL %alarm(lib_add,4000)}}
  161. //
  162. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  163. // Trigger to re-format the catalog, and add to the database.
  164. // =======================================================================================================================
  165. //
  166. #TRIGGER {^ ~ #&%d{LIBDB.bNum}&%s{LIBDB.wSpace}&{LIBDB.bTitle}$} {#GAG} {} "LIBDB"
  167. #COND {^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ by (*)$} {
  168. #LOCAL $a $b $c $d $e $f $h $k
  169. $b=%1
  170. $a=%replace(@LIBDB.bTitle,&,and)
  171. $a=%stripq($a)
  172. $a=%replace($a,~,-)
  173. #IF ($a = "(copy)") {$a="No Title";LIBDB.wSpace=%leftback(@LIBDB.wSpace,1)}
  174. #FORALL {A copy of |a copy of | (copy)|(copy) } {$a=%remove(%i,$a)}
  175. #IF (%len($a) = 0) {$a="No Title"}
  176. #IF (@LIBDB.Update) {
  177. $j=%find(@LIBDB.bNum,All,bNum)
  178. $k=1
  179. #FORALL $j {#IF (%db(%i,bNum) = @LIBDB.bNum && %db(%i,Author) = $b) {$k=0}}
  180. #IF ($k) {
  181. #NEW All bNum=@LIBDB.bNum Author=$b Title=$a Category=@LIBDB.Category vNum=@LIBDB.vNum
  182. }
  183. }
  184. $d=%find($a,All,Title)
  185. #IF (%numitems($d)) {
  186. #FORALL ($d) {
  187. #IF (%db(%i,Author)=$b && %ismember(%db(%i,vNum),@LIBDB.Compare)) {$f=1}
  188. }
  189. }
  190. #SUB {@LIBDB.wSpace%ansi(6)<send 'read @LIBDB.bNum|take 500 gold from pack;library copy @LIBDB.bNum|library remove @LIBDB.bNum|LIBDB.cat_add=@LIBDB.bNum;#RAISE move_cat' 'Read|Copy|Remove|Categorize'>@LIBDB.bNum</send> %ansi(8): %if($f,%ansi(2),%ansi(4))X %ansi(8): %ansi(3)$a %ansi(8)by %ansi(3)$b}
  191. } {} "LIBDB"
  192. //
  193. #CLASS 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement