SCRIPTS 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. #nop -------------------------------------------------------------------------
  2. #nop Learn by example
  3. #nop -------------------------------------------------------------------------
  4. #nop -------------------------------------------------------------------------
  5. #nop Loop through room 1 to 1000 and change the color of rooms with the
  6. #nop static (16) flag to <168>.
  7. #nop -------------------------------------------------------------------------
  8. #loop 1 1000 vnum
  9. {
  10. #map at $vnum
  11. {
  12. #map get roomflags result;
  13. #if {$result & 16}
  14. {
  15. #map set roomcolor <168>
  16. }
  17. }
  18. }
  19. #nop -------------------------------------------------------------------------
  20. #nop Capture system information. #script stores the output as a list,
  21. #nop hence the need to convert it into a normal variable.
  22. #nop -------------------------------------------------------------------------
  23. #script {dir} {pwd}
  24. #var dir $dir[1]
  25. #script {home} {echo $HOME}
  26. #var home $home[1]
  27. #nop -------------------------------------------------------------------------
  28. #nop Automatically reconnect on disconnect.
  29. #nop -------------------------------------------------------------------------
  30. #event {SESSION CONNECTED}
  31. {
  32. #event {SESSION DISCONNECTED}
  33. {
  34. #gts #delay 5 {#session %0 %1 %3}
  35. }
  36. }
  37. #nop -------------------------------------------------------------------------
  38. #nop Execute a random social at random time intervals.
  39. #nop -------------------------------------------------------------------------
  40. #tick {randomsocial}
  41. {
  42. #delay {1d180}
  43. {
  44. #switch {1d4}
  45. {
  46. #case {1} {cheer}
  47. #case {2} {greet all}
  48. #case {3} {smile}
  49. #case {4} {laugh self}
  50. }
  51. }
  52. }
  53. {200}
  54. #nop -------------------------------------------------------------------------
  55. #nop Maintain a friendlist. %i creates a case insensitive regex.
  56. #nop -------------------------------------------------------------------------
  57. #variable {friendlist}
  58. {
  59. {bubba};{pamela};{cookie};{harry potter}
  60. }
  61. #function isfriend
  62. {
  63. #return &friendlist[%i%0];
  64. }
  65. #act {%1 follows you.}
  66. {
  67. #if {@isfriend{%1}}
  68. {
  69. group %1
  70. };
  71. #else
  72. {
  73. unfollow %1
  74. }
  75. }
  76. #alias {addfriend}
  77. {
  78. #format name %l {%0};
  79. #var friendlist[$name] {};
  80. #showme $name has been added to your friendlist.
  81. }
  82. #alias {delfriend}
  83. {
  84. #format name %l {%0};
  85. #if {@isfriend{$name}}
  86. {
  87. #unvar friendlist[$name];
  88. #showme $name has been deleted from your friendlist.
  89. };
  90. #else
  91. {
  92. #showme $name is not on your friendlist.
  93. }
  94. }
  95. #nop -------------------------------------------------------------------------
  96. #nop Append a goto to your current room when saving a map. You can use
  97. #nop #map return instead.
  98. #nop -------------------------------------------------------------------------
  99. #alias {savemap}
  100. {
  101. #map write %0;
  102. #map get roomvnum room;
  103. #system echo '#map goto $room' >> %0
  104. }
  105. #nop -------------------------------------------------------------------------
  106. #nop Log all text to a file with a timestamp with decisecond precision.
  107. #nop -------------------------------------------------------------------------
  108. #function {timestamp}
  109. {
  110. #format utime {%U};
  111. #format result {%t.%m} {%Y-%m-%d %H:%M:%S} {$utime % 1000000 / 100000}
  112. }
  113. #event {RECEIVED LINE}
  114. {
  115. #line log mylog.txt {<178>@timestamp{} \};
  116. #line log mylog.txt
  117. }
  118. #nop -------------------------------------------------------------------------
  119. #nop Old school tick support.
  120. #nop -------------------------------------------------------------------------
  121. #tick {oldtick}
  122. {
  123. #delay 50 #showme #10 SECONDS TO TICK!!;
  124. #showme #TICK!!!
  125. }
  126. {60}
  127. #nop -------------------------------------------------------------------------
  128. #nop Execute speedwalks with .
  129. #nop -------------------------------------------------------------------------
  130. #alias {.%0}
  131. {
  132. #var cnt {};
  133. #parse {%0} {char}
  134. {
  135. #if {"$char" >= "0" && "$char" <= "9"}
  136. {
  137. #var cnt $cnt$char
  138. };
  139. #elseif {"$cnt" == ""}
  140. {
  141. #send $char
  142. };
  143. #else
  144. {
  145. #$cnt #send $char;
  146. #var cnt {}
  147. }
  148. }
  149. }
  150. #nop -------------------------------------------------------------------------
  151. #nop Targetting script
  152. #nop -------------------------------------------------------------------------
  153. #var targets {}
  154. #alias {target}
  155. {
  156. #if {"%0" == ""}
  157. {
  158. #showme {Current targets: $targets[]}
  159. };
  160. #elseif {&targets[%0]}
  161. {
  162. #unvar targets[%0];
  163. #showme Target '%0' removed.
  164. };
  165. #else
  166. {
  167. #var targets[%0] {};
  168. #showme Target '%0' added.
  169. }
  170. }
  171. #act {%1 arrives}
  172. {
  173. #if {&targets[%1]} {kill %1}
  174. }
  175. #act {%1 is standing here}
  176. {
  177. #if {&targets[%1]} {kill %1}
  178. }
  179. #action {%1 is dead! R.I.P.}
  180. {
  181. #if {&targets[%1]} {target %1}
  182. }
  183. #nop -------------------------------------------------------------------------
  184. #nop Show xterm 256 colors.
  185. #nop -------------------------------------------------------------------------
  186. #var temp {}
  187. #foreach {0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15} {var1}
  188. {
  189. #showme {$var1 \e[38;5;${var1}m}
  190. }
  191. #foreach {a;b;c;d;e;f} {var1}
  192. {
  193. #foreach {a;b;c;d;e;f} {var2}
  194. {
  195. #foreach {a;b;c;d;e;f} {var3}
  196. {
  197. #var temp {$temp <$var1$var2$var3><<888>$var1$var2$var3>}
  198. };
  199. #showme $temp;
  200. #var temp {}
  201. }
  202. }
  203. #loop 0 23 cnt
  204. {
  205. #format temp {$temp <g%+02s><<888>g%+02s} {$cnt} {$cnt};
  206. }
  207. #showme $temp
  208. #nop -------------------------------------------------------------------------
  209. #nop Draw a health bar.
  210. #nop -------------------------------------------------------------------------
  211. #alias {hpbar}
  212. {
  213. #math {hp_percent}{100 * %1 / %2};
  214. #math {hpbars1} {$hp_percent / 5};
  215. #math {hpbars2} {20 - $hpbars1};
  216. #format {hpbar} {<011>%+${hpbars1}s<099><000>%+${hpbars2}s<099> };
  217. #showme [$hpbar]
  218. }
  219. #alias {test}
  220. {
  221. hpbar 30 100
  222. }
  223. #nop -------------------------------------------------------------------------
  224. #nop Syntax: sleep <seconds to delay> {commands}
  225. #nop
  226. #nop If there is already a pending sleep the delay will be stacked.
  227. #nop -------------------------------------------------------------------------
  228. #var sleeptime 0
  229. #var sleepcurr 0
  230. #alias {sleep %1 %2}
  231. {
  232. #format sleeptime %U;
  233. #if {$sleeptime > $sleepcurr}
  234. {
  235. #math sleepcurr $sleeptime + (%1) * 1000000;
  236. #delay {%1} %2;
  237. };
  238. #else
  239. {
  240. #math sleepcurr $sleepcurr + (%1) * 1000000;
  241. #delay {($sleepcurr - $sleeptime) / 1000000.000} %2
  242. }
  243. }
  244. #nop -------------------------------------------------------------------------
  245. #nop This function and substitution will highlight spelling errors as red.
  246. #nop -------------------------------------------------------------------------
  247. #function spellcheck
  248. {
  249. #format result %S %1;
  250. #if {$result == 0}
  251. {
  252. #var result %1
  253. };
  254. #else
  255. {
  256. #var result <118>%1<278>
  257. }
  258. }
  259. #substitute {{\b[a-zA-Z]+\b}} {@spellcheck{%1}}
  260. #nop -------------------------------------------------------------------------
  261. #nop This function tests the random number engine
  262. #nop -------------------------------------------------------------------------
  263. #alias random
  264. {
  265. #var random {};
  266. #loop 1 1000 cnt
  267. {
  268. #math tmp 1d1000000000 % 10;
  269. #math random[$tmp] $random[$tmp] + 1
  270. };
  271. #var random
  272. }
  273. #nop -------------------------------------------------------------------------
  274. #nop This macro allows pasting multi-line code fragments on pressing ctrl-v
  275. #nop -------------------------------------------------------------------------
  276. #macro {\cv}
  277. {
  278. #cursor {convert meta} on;
  279. #line oneshot #event {CATCH RECEIVED INPUT}
  280. {
  281. #line sub {esc} #var paste {%0};
  282. #replace paste {\\n\\n} {;};
  283. #replace paste {\\n} {};
  284. #replace paste {\\t} {};
  285. #replace paste {;;} {;};
  286. #1 {$paste}
  287. }
  288. }
  289. #nop -------------------------------------------------------------------------
  290. #nop This macro allows pasting multi-line code fragments on pressing ctrl-v
  291. #nop followed by pressing ctrl-enter
  292. #nop -------------------------------------------------------------------------
  293. #macro {\e[13;5u}
  294. {
  295. #cursor get tmp;
  296. #cursor home;
  297. #cursor set {#line sub esc };
  298. #cursor enter
  299. }
  300. #nop -------------------------------------------------------------------------
  301. #nop This event will cause tintin to always report your screen width as 80
  302. #nop columns
  303. #nop -------------------------------------------------------------------------
  304. #event {CATCH IAC DO NAWS}
  305. {
  306. #screen get rows ROWS;
  307. #format ROWS %a $ROWS;
  308. #send {\xFF\xFB\x1F\xFF\xFA\x1F\x50\x00${ROWS}\x00\xFF\xF0\}
  309. }
  310. #nop -------------------------------------------------------------------------
  311. #nop Remove duplicate lines and add a counter. Does not work in gts because
  312. #nop it uses named delays.
  313. #nop -------------------------------------------------------------------------
  314. #var repeat[str] {}
  315. #var repeat[cnt] 1
  316. #act {~%+}
  317. {
  318. #if {{%0} === {$repeat[str]}}
  319. {
  320. #math repeat[cnt] $repeat[cnt] + 1;
  321. #delay {repeat} {repeat_show} {0}
  322. };
  323. #else
  324. {
  325. repeat_show;
  326. #var repeat[str] {%0}
  327. };
  328. #line gag
  329. }
  330. #alias {repeat_check}
  331. {
  332. #if {$repeat[cnt] <= 1}
  333. {
  334. #line ignore #showme {$repeat[str]}
  335. };
  336. #else
  337. {
  338. #line ignore #showme {($repeat[cnt]) %0}
  339. };
  340. #var repeat[str] {};
  341. #var repeat[cnt] 1
  342. }
  343. #nop -------------------------------------------------------------------------
  344. #nop These macros will allow you to move around with the arrow keys while
  345. #nop holding down the control key. You can move ne by pressing arrow up +
  346. #nop right simultaniously. Move up by pressing arrow up + down simultaniously.
  347. #nop Move down by pressing arrow left + right simultaniously.
  348. #nop -------------------------------------------------------------------------
  349. #macro {\e[1;5A} {#cursor preserve;#delay {move} {#cursor reset_macro;n} {0.05}}
  350. #macro {\e[1;5C} {#cursor preserve;#delay {move} {#cursor reset_macro;e} {0.05}}
  351. #macro {\e[1;5B} {#cursor preserve;#delay {move} {#cursor reset_macro;s} {0.05}}
  352. #macro {\e[1;5D} {#cursor preserve;#delay {move} {#cursor reset_macro;w} {0.05}}
  353. #macro {\e[1;5A\e[1;5A} {#undelay {move};#cursor reset_macro;n;n}
  354. #macro {\e[1;5C\e[1;5C} {#undelay {move};#cursor reset_macro;e;e}
  355. #macro {\e[1;5B\e[1;5B} {#undelay {move};#cursor reset_macro;s;s}
  356. #macro {\e[1;5D\e[1;5D} {#undelay {move};#cursor reset_macro;w;w}
  357. #macro {\e[1;5A\e[1;5B} {#undelay {move};#cursor reset_macro;u}
  358. #macro {\e[1;5B\e[1;5A} {#undelay {move};#cursor reset_macro;u}
  359. #macro {\e[1;5C\e[1;5D} {#undelay {move};#cursor reset_macro;d}
  360. #macro {\e[1;5D\e[1;5C} {#undelay {move};#cursor reset_macro;d}
  361. #macro {\e[1;5A\e[1;5C} {#undelay {move};#cursor reset_macro;ne}
  362. #macro {\e[1;5C\e[1;5A} {#undelay {move};#cursor reset_macro;ne}
  363. #macro {\e[1;5B\e[1;5C} {#undelay {move};#cursor reset_macro;se}
  364. #macro {\e[1;5C\e[1;5B} {#undelay {move};#cursor reset_macro;se}
  365. #macro {\e[1;5D\e[1;5B} {#undelay {move};#cursor reset_macro;sw}
  366. #macro {\e[1;5B\e[1;5D} {#undelay {move};#cursor reset_macro;sw}
  367. #macro {\e[1;5D\e[1;5A} {#undelay {move};#cursor reset_macro;nw}
  368. #macro {\e[1;5A\e[1;5D} {#undelay {move};#cursor reset_macro;nw}
  369. #nop -------------------------------------------------------------------------
  370. #nop Place tells in the top 5 lines of the screen
  371. #nop -------------------------------------------------------------------------
  372. #VARIABLE {COMMS} {}
  373. #ACTION {~%1 tells you %2}
  374. {
  375. addtowin %1 tells you %2
  376. }
  377. #ACTION {~%1 chats %2}
  378. {
  379. addtowin %1 chats %2
  380. }
  381. #ALIAS {addtowin}
  382. {
  383. #format temp {%w} {%0};
  384. #loop {1} {&temp[]} {cnt}
  385. {
  386. #list COMMS ins -1 {$temp[$cnt]}
  387. };
  388. #while {&COMMS[] > 100}
  389. {
  390. #list COMMS del 1
  391. };
  392. showwin
  393. }
  394. #ALIAS {showwin}
  395. {
  396. #screen clear square 1 1 5 -1;
  397. #list temp create $COMMS[-5..-1];
  398. #loop {1} {&temp[]} {cnt}
  399. {
  400. #regexp {$temp[$cnt]} {^$}
  401. {
  402. #nop
  403. };
  404. #else
  405. {
  406. #line ignore #showme {$temp[$cnt]} {$cnt} {1}
  407. }
  408. }
  409. }
  410. #ALIAS {test}
  411. {
  412. #split 5 1;
  413. #showme <138>Bubba tells you 'hello';
  414. #showme <158>Pamela chats 'bye';
  415. }