SCRIPTS 24 KB

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