SCRIPTS 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  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. #alias {color_static}
  9. {
  10. #loop 1 1000 vnum
  11. {
  12. #map at $vnum
  13. {
  14. #map get roomflags result;
  15. #if {$result & 16}
  16. {
  17. #map set roomcolor <168>
  18. }
  19. }
  20. }
  21. }
  22. #nop -------------------------------------------------------------------------
  23. #nop Capture system information. #script stores the output as a list,
  24. #nop hence the need to convert it into a normal variable.
  25. #nop -------------------------------------------------------------------------
  26. #script {dir} {pwd}
  27. #var dir $dir[1]
  28. #script {home} {echo $HOME}
  29. #var home $home[1]
  30. #nop -------------------------------------------------------------------------
  31. #nop Automatically reconnect on disconnect.
  32. #nop -------------------------------------------------------------------------
  33. #event {SESSION CONNECTED}
  34. {
  35. #event {SESSION DISCONNECTED}
  36. {
  37. #gts #delay 5 {#session %0 %1 %3}
  38. }
  39. }
  40. #nop -------------------------------------------------------------------------
  41. #nop Execute a random social at random time intervals.
  42. #nop -------------------------------------------------------------------------
  43. #tick {randomsocial}
  44. {
  45. #delay {1d180}
  46. {
  47. #switch {1d4}
  48. {
  49. #case {1} {cheer};
  50. #case {2} {greet all};
  51. #case {3} {smile};
  52. #case {4} {laugh self}
  53. }
  54. }
  55. }
  56. {200}
  57. #nop -------------------------------------------------------------------------
  58. #nop Maintain a friendlist. %i creates a case insensitive regex.
  59. #nop -------------------------------------------------------------------------
  60. #variable {friendlist}
  61. {
  62. {bubba};{pamela};{cookie};{harry potter}
  63. }
  64. #function isfriend
  65. {
  66. #return &friendlist[%i%0];
  67. }
  68. #act {%1 follows you.}
  69. {
  70. #if {@isfriend{%1}}
  71. {
  72. group %1
  73. };
  74. #else
  75. {
  76. unfollow %1
  77. }
  78. }
  79. #alias {addfriend}
  80. {
  81. #format name %l {%0};
  82. #var friendlist[$name] {};
  83. #showme $name has been added to your friendlist.
  84. }
  85. #alias {delfriend}
  86. {
  87. #format name %l {%0};
  88. #if {@isfriend{$name}}
  89. {
  90. #unvar friendlist[$name];
  91. #showme $name has been deleted from your friendlist.
  92. };
  93. #else
  94. {
  95. #showme $name is not on your friendlist.
  96. }
  97. }
  98. #nop -------------------------------------------------------------------------
  99. #nop Append a goto to your current room when saving a map. Alternatively, you
  100. #nop can use #map return.
  101. #nop -------------------------------------------------------------------------
  102. #alias {savemap}
  103. {
  104. #map write %0;
  105. #map get roomvnum room;
  106. #system echo '#map goto $room' >> %0
  107. }
  108. #nop -------------------------------------------------------------------------
  109. #nop Log all text to a file with a timestamp with decisecond precision.
  110. #nop Alternatively you can use #log timestamp.
  111. #nop -------------------------------------------------------------------------
  112. #function {timestamp}
  113. {
  114. #format utime {%U};
  115. #format result {%t.%m} {%Y-%m-%d %H:%M:%S} {$utime % 1000000 / 100000}
  116. }
  117. #event {RECEIVED LINE}
  118. {
  119. #line log mylog.txt {<178>@timestamp{} \};
  120. #line log mylog.txt
  121. }
  122. #nop -------------------------------------------------------------------------
  123. #nop Old school tick support.
  124. #nop -------------------------------------------------------------------------
  125. #tick {oldtick}
  126. {
  127. #delay 50 #showme #10 SECONDS TO TICK!!;
  128. #showme #TICK!!!
  129. }
  130. {60}
  131. #alias {tickers}
  132. {
  133. #info tickers save;
  134. #echo {<128>%+20s %+20s %+20s} {Name} {Interval} {Remaining};
  135. #draw Yellow scroll line 1 1 1 62;
  136. #format utime %U;
  137. #loop 1 &info[TICKERS][] index
  138. {
  139. #math uval $info[TICKERS][+$index][arg3] * 1000000;
  140. #echo {%+20s %+20s %+20m}
  141. {$info[TICKERS][+$index][arg1]}
  142. {$info[TICKERS][+$index][arg3]}
  143. {($uval - ($utime - $info[TICKERS][+$index][arg4]) % $uval) / 1000000.00}
  144. }
  145. }
  146. #nop -------------------------------------------------------------------------
  147. #nop Execute speedwalks with .
  148. #nop -------------------------------------------------------------------------
  149. #alias {.%0}
  150. {
  151. #var cnt {};
  152. #parse {%0} {char}
  153. {
  154. #if {"$char" >= "0" && "$char" <= "9"}
  155. {
  156. #var cnt $cnt$char
  157. };
  158. #elseif {"$cnt" == ""}
  159. {
  160. #send $char
  161. };
  162. #else
  163. {
  164. #$cnt #send $char;
  165. #var cnt {}
  166. }
  167. }
  168. }
  169. #nop -------------------------------------------------------------------------
  170. #nop Targetting script
  171. #nop -------------------------------------------------------------------------
  172. #var targets {}
  173. #alias {target}
  174. {
  175. #if {"%0" == ""}
  176. {
  177. #showme {Current targets: $targets[]}
  178. };
  179. #elseif {&targets[%0]}
  180. {
  181. #unvar targets[%0];
  182. #showme Target '%0' removed.
  183. };
  184. #else
  185. {
  186. #var targets[%0] {};
  187. #showme Target '%0' added.
  188. }
  189. }
  190. #act {%1 arrives}
  191. {
  192. #if {&targets[%1]} {kill %1}
  193. }
  194. #act {%1 is standing here}
  195. {
  196. #if {&targets[%1]} {kill %1}
  197. }
  198. #action {%1 is dead! R.I.P.}
  199. {
  200. #if {&targets[%1]} {target %1}
  201. }
  202. #nop -------------------------------------------------------------------------
  203. #nop Show xterm 256 colors.
  204. #nop -------------------------------------------------------------------------
  205. #alias {color_table}
  206. {
  207. #var temp {};
  208. #foreach {0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15} {var1}
  209. {
  210. #showme {$var1 \e[38;5;${var1}m}
  211. };
  212. #foreach {a;b;c;d;e;f} {var1}
  213. {
  214. #foreach {a;b;c;d;e;f} {var2}
  215. {
  216. #foreach {a;b;c;d;e;f} {var3}
  217. {
  218. #var temp {$temp <$var1$var2$var3><<888>$var1$var2$var3>}
  219. };
  220. #showme $temp;
  221. #var temp {}
  222. }
  223. };
  224. #loop 0 23 cnt
  225. {
  226. #format temp {$temp <g%+02s><<888>g%+02s} {$cnt} {$cnt};
  227. };
  228. #showme $temp
  229. }
  230. #nop -------------------------------------------------------------------------
  231. #nop Draw a health bar. Alternatively: #draw bar -2 1 -2 20 {%1;%2;<faa><afa>}
  232. #nop -------------------------------------------------------------------------
  233. #alias {hpbar}
  234. {
  235. #math {hp_percent}{100 * %1 / %2};
  236. #math {hpbars1} {$hp_percent / 5};
  237. #math {hpbars2} {20 - $hpbars1};
  238. #format {hpbar} {<011>%+${hpbars1}s<099><000>%+${hpbars2}s<099> };
  239. #showme [$hpbar]
  240. }
  241. #alias {test}
  242. {
  243. hpbar 30 100
  244. }
  245. #nop -------------------------------------------------------------------------
  246. #nop Syntax: sleep <seconds to delay> {commands}
  247. #nop
  248. #nop If there is already a pending sleep the delay will be stacked.
  249. #nop -------------------------------------------------------------------------
  250. #var sleeptime 0
  251. #var sleepcurr 0
  252. #alias {sleep %1 %2}
  253. {
  254. #format sleeptime %U;
  255. #if {$sleeptime > $sleepcurr}
  256. {
  257. #math sleepcurr $sleeptime + (%1) * 1000000;
  258. #delay {%1} %2;
  259. };
  260. #else
  261. {
  262. #math sleepcurr $sleepcurr + (%1) * 1000000;
  263. #delay {($sleepcurr - $sleeptime) / 1000000.000} %2
  264. }
  265. }
  266. #nop -------------------------------------------------------------------------
  267. #nop This function and substitution will highlight spelling errors as red.
  268. #nop -------------------------------------------------------------------------
  269. #function spellcheck
  270. {
  271. #format result %S %1;
  272. #if {$result == 0}
  273. {
  274. #var result %1
  275. };
  276. #else
  277. {
  278. #var result <118>%1<900>
  279. }
  280. }
  281. #substitute {{\b[a-zA-Z]+\b}} {@spellcheck{%1}}
  282. #nop -------------------------------------------------------------------------
  283. #nop This function and substitution will add a speed reader to the split line
  284. #nop -------------------------------------------------------------------------
  285. #split
  286. #function {spellcheck}
  287. {
  288. #format result %S %1;
  289. #if {$result == 0}
  290. {
  291. #var result %1
  292. };
  293. #else
  294. {
  295. #var result <118>%1<900>
  296. };
  297. #list speedread ins -1 {$result}
  298. }
  299. #substitute {{\b[a-zA-Z]+\b}} {@spellcheck{%1}}
  300. #tick {speedread}
  301. {
  302. #if {&{speedread[]}}
  303. {
  304. #draw tile -2 1 -2 20 {$speedread[1]};
  305. #list speedread delete 1
  306. }
  307. }
  308. {0.1}
  309. #nop -------------------------------------------------------------------------
  310. #nop This function tests the random number engine
  311. #nop -------------------------------------------------------------------------
  312. #alias {random}
  313. {
  314. #var random {};
  315. #loop 1 1000 cnt
  316. {
  317. #math tmp 1d1000000000 % 10;
  318. #math random[$tmp] $random[$tmp] + 1
  319. };
  320. #var random
  321. }
  322. #nop -------------------------------------------------------------------------
  323. #nop This macro allows pasting multi-line code fragments on pressing ctrl-v.
  324. #nop Alternatively, use ctrl-enter after pressing ctrl-v and pasting a script.
  325. #nop -------------------------------------------------------------------------
  326. #macro {\cv}
  327. {
  328. #cursor {convert meta} on;
  329. #line oneshot #event {CATCH RECEIVED INPUT}
  330. {
  331. #line sub {esc} #var paste {%0};
  332. #replace paste {\\n\\n} {;};
  333. #replace paste {\\n} {};
  334. #replace paste {\\t} {};
  335. #replace paste {;;} {;};
  336. #1 {$paste}
  337. }
  338. }
  339. #nop -------------------------------------------------------------------------
  340. #nop This event will cause tintin to always report your screen width as 80
  341. #nop columns
  342. #nop -------------------------------------------------------------------------
  343. #event {CATCH IAC DO NAWS}
  344. {
  345. #screen get rows ROWS;
  346. #format ROWS %a $ROWS;
  347. #send {\xFF\xFB\x1F\xFF\xFA\x1F\x50\x00${ROWS}\x00\xFF\xF0\}
  348. }
  349. #nop -------------------------------------------------------------------------
  350. #nop Remove duplicate lines and add a counter. Does not work in gts because
  351. #nop it uses named delays.
  352. #nop -------------------------------------------------------------------------
  353. #var repeat[str] {}
  354. #var repeat[cnt] 1
  355. #act {~%+}
  356. {
  357. #if {{%0} === {$repeat[str]}}
  358. {
  359. #math repeat[cnt] $repeat[cnt] + 1;
  360. #delay {repeat} {repeat_show} {0}
  361. };
  362. #else
  363. {
  364. repeat_show;
  365. #var repeat[str] {%0}
  366. };
  367. #line gag
  368. }
  369. #alias {repeat_show}
  370. {
  371. #if {$repeat[cnt] <= 1}
  372. {
  373. #line ignore #showme {$repeat[str]}
  374. };
  375. #else
  376. {
  377. #line ignore #showme {<128>($repeat[cnt]) <088>$repeat[str]}
  378. };
  379. #var repeat[str] {};
  380. #var repeat[cnt] 1
  381. }
  382. #nop -------------------------------------------------------------------------
  383. #nop These macros will allow you to move around with the arrow keys while
  384. #nop holding down the control key. You can move ne by pressing arrow up +
  385. #nop right simultaniously. Move up by pressing arrow up + down simultaniously.
  386. #nop Move down by pressing arrow left + right simultaniously.
  387. #nop -------------------------------------------------------------------------
  388. #macro {\e[1;5A} {#cursor macro preserve;#delay {move} {#cursor macro reset;n} {0.05}}
  389. #macro {\e[1;5C} {#cursor macro preserve;#delay {move} {#cursor macro reset;e} {0.05}}
  390. #macro {\e[1;5B} {#cursor macro preserve;#delay {move} {#cursor macro reset;s} {0.05}}
  391. #macro {\e[1;5D} {#cursor macro preserve;#delay {move} {#cursor macro reset;w} {0.05}}
  392. #macro {\e[1;5A\e[1;5A} {#undelay {move};#cursor macro reset;n;n}
  393. #macro {\e[1;5C\e[1;5C} {#undelay {move};#cursor macro reset;e;e}
  394. #macro {\e[1;5B\e[1;5B} {#undelay {move};#cursor macro reset;s;s}
  395. #macro {\e[1;5D\e[1;5D} {#undelay {move};#cursor macro reset;w;w}
  396. #macro {\e[1;5A\e[1;5B} {#undelay {move};#cursor macro reset;u}
  397. #macro {\e[1;5B\e[1;5A} {#undelay {move};#cursor macro reset;u}
  398. #macro {\e[1;5C\e[1;5D} {#undelay {move};#cursor macro reset;d}
  399. #macro {\e[1;5D\e[1;5C} {#undelay {move};#cursor macro reset;d}
  400. #macro {\e[1;5A\e[1;5C} {#undelay {move};#cursor macro reset;ne}
  401. #macro {\e[1;5C\e[1;5A} {#undelay {move};#cursor macro reset;ne}
  402. #macro {\e[1;5B\e[1;5C} {#undelay {move};#cursor macro reset;se}
  403. #macro {\e[1;5C\e[1;5B} {#undelay {move};#cursor macro reset;se}
  404. #macro {\e[1;5D\e[1;5B} {#undelay {move};#cursor macro reset;sw}
  405. #macro {\e[1;5B\e[1;5D} {#undelay {move};#cursor macro reset;sw}
  406. #macro {\e[1;5D\e[1;5A} {#undelay {move};#cursor macro reset;nw}
  407. #macro {\e[1;5A\e[1;5D} {#undelay {move};#cursor macro reset;nw}
  408. #nop -------------------------------------------------------------------------
  409. #nop Place tells in the top 5 lines of the screen
  410. #nop -------------------------------------------------------------------------
  411. #VARIABLE {COMMS} {}
  412. #ACTION {~%1 tells you %2}
  413. {
  414. addtowin %1 tells you %2
  415. }
  416. #ACTION {~%1 chats %2}
  417. {
  418. addtowin %1 chats %2
  419. }
  420. #ALIAS {addtowin}
  421. {
  422. #format temp {%w} {%0};
  423. #loop {1} {&temp[]} {cnt}
  424. {
  425. #list COMMS ins -1 {$temp[$cnt]}
  426. };
  427. #while {&COMMS[] > 100}
  428. {
  429. #list COMMS del 1
  430. };
  431. showwin
  432. }
  433. #ALIAS {showwin}
  434. {
  435. #screen clear square 1 1 5 -1;
  436. #list temp create $COMMS[-5..-1];
  437. #loop {1} {&temp[]} {cnt}
  438. {
  439. #regexp {$temp[$cnt]} {^$}
  440. {
  441. #nop
  442. };
  443. #else
  444. {
  445. #line ignore #showme {$temp[$cnt]} {$cnt} {1}
  446. }
  447. }
  448. }
  449. #ALIAS {test}
  450. {
  451. #split 5 1;
  452. #showme <138>Bubba tells you 'hello';
  453. #showme <158>Pamela chats 'bye';
  454. }
  455. #nop -------------------------------------------------------------------------
  456. #nop Display two sessions next to each other
  457. #nop -------------------------------------------------------------------------
  458. #event {SCREEN RESIZE}
  459. {
  460. #var ROWS %0;
  461. #var COLS %1;
  462. #draw line 1 {$COLS / 2} -3 {$COLS / 2};
  463. #left #screen scroll 1 1 -3 {$COLS / 2 - 1};
  464. #right #screen scroll 1 {$COLS / 2 + 1} -3 -1;
  465. }
  466. #event {PROGRAM START}
  467. {
  468. #screen raise SCREEN RESIZE;
  469. #ses right localhost 4321;
  470. #ses left localhost 4321;
  471. }
  472. #event {SESSION CREATED}
  473. {
  474. #var name %0;
  475. }
  476. #event {SESSION ACTIVATED}
  477. {
  478. #gts #var active %0;
  479. }
  480. #event {RECEIVED OUTPUT}
  481. {
  482. #if {"@gts{$active}" == "$name"}
  483. {
  484. #return;
  485. };
  486. #switch {"$name"}
  487. {
  488. #case {"left"} {#draw Red boxed foreground buffer 1 1 -3 {$COLS / 2 - 1};};
  489. #case {"right"}{#draw Red boxed foreground buffer 1 {$COLS / 2 + 1} -3 -1};
  490. };
  491. }
  492. #nop -------------------------------------------------------------------------
  493. #nop Follow the group leader on the map.
  494. #nop -------------------------------------------------------------------------
  495. #var short_dir
  496. {
  497. {north}{n}
  498. {northeast}{ne}
  499. {east}{e}
  500. {southeast}{se}
  501. {south}{s}
  502. {southwest}{sw}
  503. {west}{w}
  504. {northwest}{nw}
  505. }
  506. #action {%1 walks %2.$}
  507. {
  508. #var {follow_targets[%1]} {$short_dir[%2]}
  509. }
  510. #action {^You follow %1.$}
  511. {
  512. #if {&follow_targets[%1]}
  513. {
  514. #map move $follow_targets[%1]
  515. }
  516. }
  517. #nop -------------------------------------------------------------------------
  518. #nop Use mouse click to change the input cursor's position.
  519. #nop -------------------------------------------------------------------------
  520. #config mouse on
  521. #split
  522. #event {SHORT-CLICKED MOUSE BUTTON ONE -1}
  523. {
  524. #cursor position %1
  525. }
  526. #nop -------------------------------------------------------------------------
  527. #nop Move the VT100 map from the top to the right of the screen
  528. #nop -------------------------------------------------------------------------
  529. #map create
  530. #map flag vtmap
  531. #map flag unicode
  532. #map goto 1
  533. #split 0 1 0 -80;
  534. #map offset 1 82 -5 -1
  535. #screen resize horizontal 120
  536. #nop -------------------------------------------------------------------------
  537. #nop Add clickable session tabs at the top of the screen
  538. #nop -------------------------------------------------------------------------
  539. #event {PROGRAM START}
  540. {
  541. #split 3 1;
  542. #config mouse on;
  543. #var active gts;
  544. session_activated gts;
  545. }
  546. #event {SESSION CREATED}
  547. {
  548. #gts session_activated %0
  549. }
  550. #event {SESSION ACTIVATED}
  551. {
  552. #gts session_activated %0
  553. }
  554. #alias {session_activated}
  555. {
  556. #line sub esc #var sessions[$active] {<138>\e]68;2;TABS;#$active\a\e[4;24m$active\e[24m};
  557. #var active {%0};
  558. #line sub esc #var sessions[%0] {<128>\e]68;2;TABS;#nop\a\e[4;24m%0\e[24m};
  559. #draw foreground Azure table 1 1 3 -1 {$sessions[%*]}
  560. }
  561. #event {PRESSED SECURE LINK TABS MOUSE BUTTON ONE}
  562. {
  563. %4
  564. }
  565. #nop -------------------------------------------------------------------------
  566. #nop Add basic MXP link and color handling
  567. #nop -------------------------------------------------------------------------
  568. #config mouse on
  569. #event {IAC DO MXP}
  570. {
  571. #send {\xFF\xFB\x5B\}
  572. }
  573. #function {mxp_link}
  574. {
  575. #line sub esc #var result {\e]68;1;%1;%2\a\e[4m%3\e[24m}
  576. }
  577. #act {~\e[1z<VERSION>} {#send {\e[4z<VERSION MXP=1.0 CLIENT=TINTIN++ VERSION=2.02.04>}}
  578. #act {~\e[1z<SUPPORT>} {#send {\e[4z<SUPPORTS +SEND +COLOR>}}
  579. #sub {~\e[4z<COLOR #%1>%2\e[4z</COLOR>} {<f%1>%2<900>}
  580. #sub {~\e[4z<SEND HREF="%1">%2\e[4z</SEND>} {@mxp_link{MXP;%1;%2}}
  581. #event {PRESSED LINK MXP MOUSE BUTTON ONE}
  582. {
  583. #send {%4}
  584. }
  585. #sub {~\e[4z{<RExits>|</RExits>|<RDesc>|</RDesc>|<PROMPT>|</PROMPT>|<RName>|</RName>}} {}
  586. #sub {~\e[4z<RNum %d />} {}
  587. #sub {&lt;} {<}
  588. #sub {&gt;} {>}
  589. #nop -------------------------------------------------------------------------
  590. #nop Example script for using #list indexing.
  591. #nop -------------------------------------------------------------------------
  592. #var players[1] {{name}{bubba}{age}{15}{level}{24}}
  593. #var players[2] {{name}{pamela}{age}{19}{level}{2}}
  594. #var players[3] {{name}{ronald}{age}{69}{level}{13}}
  595. #var players[4] {{name}{bubba}{age}{26}{level}{30}}
  596. #var players[5] {{name}{ronald}{age}{11}{level}{31}}
  597. #alias {display}
  598. {
  599. #var out {};
  600. #loop 1 &players[] cnt
  601. {
  602. #var out[$cnt] {$cnt;$players[+$cnt][name];$players[+$cnt][age];$players[+$cnt][level]};
  603. };
  604. #draw scroll grid table 1 1 2+&players[]*2 80 $out[%*]
  605. }
  606. #alias {test1}
  607. {
  608. #list players index name;
  609. #list players order;
  610. display
  611. }
  612. #alias {test2}
  613. {
  614. #list players index name;
  615. #list players order;
  616. #list players reverse;
  617. display;
  618. }
  619. #alias {test3}
  620. {
  621. #list players index name;
  622. #list players order;
  623. #list players index level;
  624. #list players order;
  625. display
  626. }
  627. #nop -------------------------------------------------------------------------
  628. #nop Example script for creating clickable menus in the scrolling region.
  629. #nop -------------------------------------------------------------------------
  630. #con mouse on
  631. #function link {#var result {\e]68;1;%1;%2\a\e[4m%3\e[24m}}
  632. #event {PRESSED LINK MENU MOUSE BUTTON ONE}
  633. {
  634. #local {link} {%4};
  635. #foreach {*link[]} {key}
  636. {
  637. #line {substitute} {variables;functions}
  638. {
  639. #var link[$key] {@link{MENU_ITEM;$link[$key];<faa>$key}}
  640. }
  641. };
  642. #draw Azure scaled box %0+1 %1 %0+1 %1+9 $link[%*]
  643. }
  644. #event {PRESSED LINK MENU_ITEM MOUSE BUTTON ONE}
  645. {
  646. #showme {<ffa>%4};
  647. #buffer refresh
  648. }
  649. #showme {Example link: @link{MENU;{{bli}{bla}{blo}{blu}};<128>click me}}
  650. #nop -------------------------------------------------------------------------
  651. #nop This creates two input lines that can be switched between using the tab
  652. #nop key.
  653. #nop -------------------------------------------------------------------------
  654. #line quiet #split
  655. #macro {\t} {inputswitch}
  656. #var input[width] 1
  657. #alias {inputswitch}
  658. {
  659. #cursor get {input[current]};
  660. #cursor clear;
  661. #cursor set {$input[buffer2]};
  662. #cursor end;
  663. #var input[buffer2] {$input[current]};
  664. #draw Ebony tile {-1-$input[width]} 1 -2 -1 {$input[buffer2]}
  665. }
  666. #nop -------------------------------------------------------------------------
  667. #nop This allows for split screen scroll back, just use the mouse wheel in
  668. #nop the upper half of the screen.
  669. #nop -------------------------------------------------------------------------
  670. #event {PROGRAM START}
  671. {
  672. #config mouse on;
  673. #var SCROLL[MODE] 0;
  674. #split 0 1;
  675. #screen raise SCREEN RESIZE;
  676. }
  677. #event {SCREEN RESIZE}
  678. {
  679. #var ROWS %0;
  680. #var COLS %1;
  681. #screen get SCROLL_TOP_ROW SCROLL[TOP_ROW];
  682. #screen get SCROLL_TOP_COL SCROLL[TOP_COL];
  683. #screen get SCROLL_BOT_ROW SCROLL[BOT_ROW];
  684. #screen get SCROLL_BOT_COL SCROLL[BOT_COL];
  685. }
  686. #EVENT {SCROLLED MOUSE WHEEL UP}
  687. {
  688. #if {$SCROLL[MODE] == 0}
  689. {
  690. #if {%0 < $ROWS / 2}
  691. {
  692. #var SCROLL[MODE] 1;
  693. #var SCROLL[OLD_ROW] $SCROLL[BOT_ROW];
  694. #math SCROLL[BOT_ROW] $SCROLL[OLD_ROW] / 2;
  695. #var BUFFER {};
  696. #screen scroll $SCROLL[TOP_ROW] $SCROLL[TOP_COL] $SCROLL[BOT_ROW] $SCROLL[BOT_COL];
  697. #draw red teed line $SCROLL[BOT_ROW]+1 $SCROLL[TOP_COL] $SCROLL[BOT_ROW]+1 $SCROLL[BOT_COL];
  698. #nop #screen clear square $SCROLL[BOT_ROW]+2 $SCROLL[TOP_COL] $SCROLL[OLD_ROW] $SCROLL[BOT_COL];
  699. };
  700. };
  701. #if {$SCROLL[MODE] == 1}
  702. {
  703. #buffer up 1
  704. }
  705. }
  706. #EVENT {SCROLLED MOUSE WHEEL DOWN}
  707. {
  708. #if {$SCROLL[MODE] == 1}
  709. {
  710. #if {%0 < $ROWS / 2}
  711. {
  712. #buffer down 1;
  713. #buffer info save SCROLL[INFO];
  714. #if {$SCROLL[INFO][LINE] == -1}
  715. {
  716. #var SCROLL[MODE] 0;
  717. #var SCROLL[BOT_ROW] $SCROLL[OLD_ROW];
  718. #split 0 1;
  719. #buffer end;
  720. }
  721. }
  722. }
  723. }
  724. #event {RECEIVED LINE}
  725. {
  726. #if {$SCROLL[MODE] == 1}
  727. {
  728. #if {&BUFFER[] > $ROWS}
  729. {
  730. #list BUFFER del 1
  731. };
  732. #list BUFFER add {%0};
  733. #draw tile $SCROLL[BOT_ROW]+2 $SCROLL[TOP_COL] $SCROLL[OLD_ROW] $SCROLL[BOT_COL] $BUFFER[%*];
  734. }
  735. }
  736. #nop -------------------------------------------------------------------------
  737. #nop This is a script to connect to Gemstone 4.
  738. #nop Visit play.net/gs4, login, and hit the 'GO PLAY' button.
  739. #nop Select the Storm Front radio button and hit the 'GO PLAY' button.
  740. #nop Save the .sal file to your script directory and name it gemstone.sal.
  741. #nop Use the 'gemstone' alias to connect.
  742. #nop -------------------------------------------------------------------------
  743. #alias {gemstone}
  744. {
  745. #var gemstone {};
  746. #line oneshot #action {^GAMEHOST=%*} {#var gemstone[host] %%1};
  747. #line oneshot #action {^GAMEPORT=%*} {#var gemstone[port] %%1};
  748. #line oneshot #action {^KEY=%*} {#var gemstone[key] %%1};
  749. #scan txt gemstone.sal;
  750. #if {&gemstone[] != 3}
  751. {
  752. #showme Failed to load gemstone.sal file.;
  753. #return
  754. };
  755. #ses gemstone $gemstone[host] $gemstone[port];
  756. #send {$gemstone[key]};
  757. #send {>/FE:JAVA}
  758. }
  759. #nop -------------------------------------------------------------------------
  760. #nop Start a dated log file in the logs directory when a session connects. See
  761. #nop #help time for the available date options for #format %t.
  762. #nop -------------------------------------------------------------------------
  763. #event {SESSION CONNECTED}
  764. {
  765. #format date %t %Y-%m-%d-%H-%M;
  766. #log append logs/%0_$date.log
  767. }
  768. #nop -------------------------------------------------------------------------
  769. #nop Sometimes an error doesn't give enough information and it's useful to
  770. #nop see the calling script.
  771. #nop -------------------------------------------------------------------------
  772. #event {RECEIVED ERROR}
  773. {
  774. #echo <118>%h { TOKENIZER };
  775. #info tokenizer -1;
  776. #echo <118>%h
  777. }
  778. #nop -------------------------------------------------------------------------
  779. #nop It can be annoying to have short commands clog up the command history.
  780. #nop This script will remove commands shorter than 3 letters.
  781. #nop -------------------------------------------------------------------------
  782. #event {HISTORY UPDATE}
  783. {
  784. #if {{%0} != {%+3*%*}}
  785. {
  786. #history delete
  787. }
  788. }
  789. #nop -------------------------------------------------------------------------
  790. #nop Run to a room when you click it on the vtmap.
  791. #nop -------------------------------------------------------------------------
  792. #config mouse on
  793. #event {MAP ROOM SHORT-CLICKED MOUSE BUTTON ONE}
  794. {
  795. #map run {%4} 0.25
  796. }
  797. #nop -------------------------------------------------------------------------
  798. #nop zMUD has the feature where your last command is highlighted and any input
  799. #nop other than enter will clear it. This scripts reproduces this behavior.
  800. #nop -------------------------------------------------------------------------
  801. #CONFIG REPEAT_ENTER ON
  802. #event {HISTORY UPDATE}
  803. {
  804. #delay 0 #line ignore #showme {<aaf><FFF><788>%0<088>} {-1};
  805. #var last_input {%0}
  806. }
  807. #event {PROCESSED KEYPRESS}
  808. {
  809. #if {{%1} != {10} && {$last_input} !== {}}
  810. {
  811. #var last_input {};
  812. #line ignore #showme {} {-1};
  813. #cursor end;
  814. #history insert {}
  815. }
  816. }
  817. #nop -------------------------------------------------------------------------
  818. #nop Digitalize a spoken number, example: wton one hundred and thirty-six
  819. #nop -------------------------------------------------------------------------
  820. #alias {wton}
  821. {
  822. #var wton {%0};
  823. #replace wton {-} {};
  824. #replace wton { and } {};
  825. #replace wton {ninety} {+90};
  826. #replace wton {eighty} {+80};
  827. #replace wton {seventy} {+70};
  828. #replace wton {sixty} {+60};
  829. #replace wton {fifty} {+50};
  830. #replace wton {forty} {+40};
  831. #replace wton {thirty} {+30};
  832. #replace wton {twenty} {+20};
  833. #replace wton {twelve} {+12};
  834. #replace wton {eleven} {+11};
  835. #replace wton {teen} {+10};
  836. #replace wton {ten} {+10};
  837. #replace wton {nine} {+9};
  838. #replace wton {eight} {+8};
  839. #replace wton {eigh} {+8};
  840. #replace wton {seven} {+7};
  841. #replace wton {six} {+6};
  842. #replace wton {five} {+5};
  843. #replace wton {fif} {+5};
  844. #replace wton {four} {+4};
  845. #replace wton {three} {+3};
  846. #replace wton {thir} {+3};
  847. #replace wton {two} {+2};
  848. #replace wton {one} {+1};
  849. #replace wton {%S billion} {+ (&1) * 1000000000};
  850. #replace wton {%S million} {+ (&1) * 1000000};
  851. #replace wton {%S thousand} {+ (&1) * 1000};
  852. #replace wton {%S hundred} {+ (&1) * 100};
  853. #math wton $wton;
  854. #line ignore #showme <118>wton %0 = $wton
  855. }
  856. #nop -------------------------------------------------------------------------
  857. #nop Utility aliases to save variables as json, and load json as variables.
  858. #nop -------------------------------------------------------------------------
  859. #alias {json_save}
  860. {
  861. #if {"%1" == "" || "%2" == ""}
  862. {
  863. #showme Syntax: json_save <variable> <filename>;
  864. #return
  865. };
  866. #line quiet #log remove %2;
  867. #line json {%1} {#line log {%2} {&0}}
  868. }
  869. #alias {json_load}
  870. {
  871. #if {"%1" == "" || "%2" == ""}
  872. {
  873. #showme Syntax: json_load <variable> <filename>;
  874. #return
  875. };
  876. #line quiet #unvar {%2};
  877. #scan json {%2} {%1}
  878. }
  879. #nop -------------------------------------------------------------------------
  880. #nop Example of switching to an editing window, with mouse support. Use #edit
  881. #nop create to start editing. After editing is finished you can use #edit save
  882. #nop to store the data to a variable.
  883. #nop -------------------------------------------------------------------------
  884. #config mouse on
  885. #event {PROGRAM START}
  886. {
  887. #screen raise {SCREEN RESIZE}
  888. }
  889. #event {SCREEN RESIZE}
  890. {
  891. #screen clear all;
  892. #screen scroll 2 2 -10 -2;
  893. #screen input -7 2 -2 -2;
  894. #draw azure rounded left right bot top side 1 1 -9 -1;
  895. #draw azure rounded left right bot top side -8 1 -1 -1
  896. }
  897. #event {PRESSED INPUT MOUSE BUTTON ONE}
  898. {
  899. #cursor position %0 %1
  900. }
  901. #event {EDIT STARTED}
  902. {
  903. #screen inputregion 2 2 -10 -2;
  904. #screen scrollregion -7 2 -2 -2
  905. }
  906. #event {CATCH EDIT FINISHED}
  907. {
  908. #screen input -7 2 -2 -2;
  909. #screen scroll 2 2 -10 -2;
  910. #showme <138>EDIT FINISHED %0. LINES: %1 SIZE: %2
  911. }
  912. #nop -------------------------------------------------------------------------
  913. #nop Example script for drawing health bars
  914. #nop -------------------------------------------------------------------------
  915. #split 26 0
  916. #screen clear top
  917. #alias {draw_bar}
  918. {
  919. #math value 0;
  920. #loop 1 26 cnt
  921. {
  922. #draw ralign tile $cnt 1 $cnt 8 <178>$value/100;
  923. #draw horizontal bar $cnt 10 $cnt 20 {$value;100;%0};
  924. #math value $value + 4
  925. }
  926. }
  927. draw_bar <faa><afa>
  928. #nop -------------------------------------------------------------------------
  929. #nop
  930. #nop -------------------------------------------------------------------------