1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607
|
<html lang="en">
<head>
<title>Mark's MUd CLient Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name=description content="Mark's MUd CLient Manual">
<meta name=generator content="makeinfo 4.1">
<link href="http://texinfo.org/" rel=generator-home>
</head>
<body>
<h1>Mark's MUd CLient Manual</h1>
<p><hr>
Node:<a name="Top">Top</a>,
Next:<a rel=next href="#About">About</a>,
Up:<a rel=up href="#dir">(dir)</a>
<br>
<h2>Mark's Mud Client Manual</h2>
<p>Mmucl (pronounced muckle) is a mud client written in Tcl.
<ul>
<li><a href="#About">About</a>: Version and author info.
<li><a href="#Copying">Copying</a>: Your rights.
<li><a href="#Overview">Overview</a>: What is Mmucl?
<li><a href="#Invocation">Invocation</a>: Starting Mmucl.
<li><a href="#Interfaces">Interfaces</a>: How you interact with Mmucl.
<li><a href="#Tutorial">Tutorial</a>: A quickstart.
<li><a href="#Scripts">Scripts</a>: Using Tcl.
<li><a href="#Patterns">Patterns</a>: Matching text.
<li><a href="#Procedures">Procedures</a>: Procedures Mmucl defines.
<li><a href="#FAQ">FAQ</a>: Frequently Asked Questions.
<li><a href="#Feedback">Feedback</a>: Reporting a bug.
</ul>
<p><hr>
Node:<a name="About">About</a>,
Next:<a rel=next href="#Copying">Copying</a>,
Previous:<a rel=previous href="#Top">Top</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>About</h2>
<p>Mmucl is maintained by Mark Patton, <a href="mailto:msp@users.sourceforge.net">msp@users.sourceforge.net</a>.
<p>The current developement version of Mmucl, with which this
manual was distributed, is 1.5.1.
<p>You can find the latest news at the Mmucl home page,
<a href="http://mmucl.sourceforge.net">http://mmucl.sourceforge.net</a>.
<p><hr>
Node:<a name="Copying">Copying</a>,
Next:<a rel=next href="#Overview">Overview</a>,
Previous:<a rel=previous href="#About">About</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Copying</h2>
<p>Mmucl is "free"; this means that everyone is free to use it and free
to redistribute it on a free basis. Mmucl is not in the public domain; it
is copyrighted and there are restrictions on its distribution, but
these restrictions are designed to permit everything that a good
cooperating citizen would want to do. What is not allowed is to try to
prevent others from further sharing any version of Mmucl that they might
get from you.
<p>Specifically, I want to make sure that you have the right to give
away copies of Mmucl, that you receive source code or else can get it if
you want it, that you can change Mmucl or use pieces of it in new free
programs, and that you know you can do these things.
<p>To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies of Mmucl, you must give the recipients all the rights that you
have. You must make sure that they, too, receive or can get the source
code. And you must tell them their rights.
<p>Also, for my own protection, I must make certain that everyone finds
out that there is no warranty for Mmucl. If Mmucl is modified by someone
else and passed on, I want their recipients to know that what they have
is not what I distributed, so that any problems introduced by others
will no reflect on my reputation.
<p>The precise conditions of the licenses for Mmucl are found in the
General Public License that accompanies it.
<p><hr>
Node:<a name="Overview">Overview</a>,
Next:<a rel=next href="#Invocation">Invocation</a>,
Previous:<a rel=previous href="#Copying">Copying</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Overview</h2>
<p>Mmucl is a MUD (Multi-User Dungeon) client. A MUD is a multi-player
role-playing game that runs as a server on a remote host.
The server accepts connections, receives input from users, decides
what to do, and sends information back.
<p>Most muds are text based. You can connect to and play on them with
a simple telnet client, but that tends to be painful. Mud clients
make mudding much more pleasant. They let you do all sorts of
useful things such as automatically responding to certain patterns
of mud output and making shortcuts for often used mud commands.
<p>Mmucl provides the features found in most mud clients such as support
for ANSI color, triggers, command line editing, aliases, multi-session
support, and macros to name a few. Mmucl's most powerful feature is
its extensibility through Tcl scripts. See <a href="#Scripts">Scripts</a>, for more info.
<p>Mmucl has a number of different interfaces from text mode to graphical,
See <a href="#Interfaces">Interfaces</a>.
<p><hr>
Node:<a name="Invocation">Invocation</a>,
Next:<a rel=next href="#Interfaces">Interfaces</a>,
Previous:<a rel=previous href="#Overview">Overview</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Invocation</h2>
<p>Usage: <code>mmucl</code> [<var>interface</var>] <var>option</var><small>...</small>
<p><var>interface</var> indicates which of several interfaces you wish to
use, see <a href="#Interfaces">Interfaces</a> for information.
<p>Options:
<dl>
<br><dt><code>-h --help</code>
<dd>Print this message and exit
<br><dt><code>-v --version</code>
<dd>Print the version and exit
<br><dt><code>-e --eval <var>script</var></code>
<dd>Start mmucl and eval <var>script</var>
</dl>
<p>The environment variable <code>TCLLIBPATH</code> can be used to specify
where Mmucl looks for Tcl extensions.
<p><hr>
Node:<a name="Interfaces">Interfaces</a>,
Next:<a rel=next href="#Tutorial">Tutorial</a>,
Previous:<a rel=previous href="#Invocation">Invocation</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Interfaces</h2>
<p>Mmucl has a number of different interfaces, some of which require other
libraries installed to run.
<dl>
<dt><code>tk</code>
<dd><code>tk</code> is a GUI interface that requires Tk. This is the default.
<br><dt><code>gnome</code>
<dd><code>gnome</code> is a gui interface that requires Tcl-Gtk,
<a href="http://tcl-gtk.sourceforge.net">http://tcl-gtk.sourceforge.net</a>, and Gnome2,
<a href="http://www.gnome.org">http://www.gnome.org</a>. It is by far the prettiest interface.
<br><dt><code>readline</code>
<dd><code>readline</code> is a basic text interface that requires tclreadline,
<a href="tclreadline.sourceforge.net">tclreadline.sourceforge.net</a>
<br><dt><code>text</code>
<dd><code>text</code> is an extremely simple text interface that works on any terminal.
</dl>
<p><hr>
Node:<a name="Tutorial">Tutorial</a>,
Next:<a rel=next href="#Scripts">Scripts</a>,
Previous:<a rel=previous href="#Interfaces">Interfaces</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Tutorial</h2>
<p>This is a brief introduction to the basics of using Mmucl.
<p>Most of your interaction with Mmucl will be through the command
line.
<p>To connect to a mud, type <code>/connect <var>host</var> <var>port</var></code>.
<p>Mmucl will try to connect to the mud running on <var>host</var> at
port <var>port</var>.
<p>The character <code>/</code> at the beginning of input
indicates that the rest of the string is a command to the client
in the form of a Tcl script, see <a href="#Scripts">Scripts</a>.
In this case a procedure,
<code>connect</code>, is executed with <var>host</var> and <var>port</var> as arguments.
<p>The input <code>e;e</code> is equivalent to typing in <code>e</code> twice.
<p>If input begins with <code>\</code>, then input minus the
beginning <code>\</code> is sent to the mud. You might use this to
avoid the special interpretation of <code>;</code>.
For example <code>\alias x equip;hide</code> would send <code>alias x equip;hide</code>
to the mud.
<p>If the first word of input matches an alias name, the alias
is executed.
For example if you had an alias <code>k</code> and typed <code>k blob</code> then
the alias would be evaluated with an argument of blob.
For more information on aliases, see <a href="#alias">alias</a>.
<p>For a more exact description of command line interpretation,
see <a href="#parse">parse</a>.
<p>Here are some examples of useful things Mmucl can do.
You may not necessarily understand all the examples, but you should be
able to use them as templates and figure out how they work later.
<p>Note that the examples are Tcl scripts. You can use them by typing
<code>/</code> followed by the script in the client. Alternately, and
much recommended, use a real editor, save them to a file, and
load them with <code>/source file</code>.
<p>Make an alias named <code>h</code> to send the command
<code>cast cure critical wounds me</code> to the mud.
The <code>write</code> procedure sends each of its arguments
to the mud.
<br><pre>alias set h {
write "cast cure critical wounds me"
}
</pre>
<p>Even better, bind the command to a key.
We'll bind it to F1. See <a href="#key">key</a>, for more
about binding keys.
<br><pre>key set F1 {
write "cast cure critical wounds me"
}
</pre>
<p>Suppose we want to heal someone else? We'll make an
h alias that heals someone else if given an argument
and heals us if given no arguments.
<p>The variable <code>$0</code> is the argument string given to the
alias. The variable <code>$1</code> is the first <dfn>word</dfn>, a sequence
of non-space characters, in <code>$0</code>.
<br><pre>alias set h {
if {$1 ne ""} {
write "cast cure critical wounds $0"
} else {
write "cast cure critical wounds me"
}
}
</pre>
<p>Maybe we should heal ourselves automatically whenever
we get <code>Bob CRUSHES you to the ground</code> sent from
the mud. Actions execute commands whenever their pattern
matches output from the mud. See <a href="#action">action</a>, for more
information.
<br><pre>action set {Bob CRUSHES you to the ground} {
write "cast cure critical wounds me"
}
</pre>
<p>How about generalizing the action so we get healed
when any monster crushes us? We can use <code>%w</code> in
the pattern to match the monster's name. (If the
monster's name has spaces in it, use <code>%s</code>
instead.) See <a href="#Format">Format</a>, for a detailed description
of the pattern syntax.
<br><pre>action set {%w CRUSHES you to the ground} {
write "cast cure critical wounds me"
}
</pre>
<p>One problem with the action is that someone could
give us a tell, <code>Jerk tells you: bear CRUSHES you to the ground</code>
and trigger the action. To prevent that we want
to have the action only be triggered when
<code>%w CRUSHES you to the ground</code> is at the beginning
of a line. We can do that with <code>^</code> which matches
the beginning of a line.
<br><pre>action set {^%w CRUSHES you to the ground} {
write "cast cure critical wounds me"
}
</pre>
<p>Now suppose we want to automatically heal our friends
when they tell us "heal me".
The variable <code>$1</code> is the first match in the
pattern counting from left to right.
<br><pre>action set {^%w tells you: heal me} {
write "cast cure critical wounds $1"
}
</pre>
<p><hr>
Node:<a name="Scripts">Scripts</a>,
Next:<a rel=next href="#Patterns">Patterns</a>,
Previous:<a rel=previous href="#Tutorial">Tutorial</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Scripts</h2>
<p>Mmucl is written in the scripting language Tcl and is
extendable through that same language. Mmucl makes a great
deal of its functionality available to the user through
commands it defines. See <a href="#Procedures">Procedures</a>.
<p>To execute a Tcl command in Mmucl prepend the command with
whatever the character config option <code>script_char</code>
is set to, by default <code>/</code>.
<p>Most of the time you will want to use a real editor and write
the scripts to a file. Then you can load them into Mmucl with
<code>/source file</code>.
<p>On startup Mmucl loads <code>.mmucl2/mmucl.rc</code> if it exists.
<ul>
<li><a href="#Syntax">Syntax</a>:
<li><a href="#Basics">Basics</a>:
<li><a href="#Errors">Errors</a>:
<li><a href="#Arrays">Arrays</a>:
<li><a href="#Lists">Lists</a>:
<li><a href="#New%20commands">New commands</a>:
<li><a href="#Tips">Tips</a>:
<li><a href="#Examples">Examples</a>:
</ul>
<p><hr>
Node:<a name="Syntax">Syntax</a>,
Next:<a rel=next href="#Basics">Basics</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Syntax</h3>
<p>Taken directly from the Tcl docs:
<p>The following rules define the syntax
and semantics of the Tcl language.
<ol type=1 start=1>
</p><li>A Tcl script is a string containing one or more
commands. Semi-colons and newlines are command
separators unless quoted as described below. Close
brackets are command terminators during command
substitution (see below) unless quoted.
<li>A command is evaluated in two steps. First, the
Tcl interpreter breaks the command into words and
performs substitutions as described below. These
substitutions are performed in the same way for all
commands. The first word is used to locate a command
procedure to carry out the command, then all
of the words of the command are passed to the command
procedure. The command procedure is free to
interpret each of its words in any way it likes,
such as an integer, variable name, list, or Tcl
script. Different commands interpret their words differently.
<li>Words of a command are separated by white space
(except for newlines, which are command separators).
<li>If the first character of a word is double-quote
<code>"</code> then the word is terminated by the next
double-quote character. If semi-colons, close
brackets, or white space characters (including newlines)
appear between the quotes then they are treated as
ordinary characters and included in the word. Command
substitution, variable substitution, and backslash
substitution are performed on the characters between
the quotes as described below. The double-quotes are not
retained as part of the word.
<li>If the first character of a word is an open brace
<code>{</code> then the word is terminated by the matching
close brace <code>}</code>. Braces nest within the word:
for each additional open brace there must be an
additional close brace (however, if an open brace
or close brace within the word is quoted with a
backslash then it is not counted in locating the
matching close brace). No substitutions are
performed on the characters between the braces
except for backslash-newline substitutions
described below, nor do semi-colons, newlines,
close brackets, or white space receive any special
interpretation. The word will consist of exactly
the characters between the outer braces, not
including the braces themselves.
<li>If a word contains an open bracket <code>[</code> then Tcl
performs command substitution. To do this it
invokes the Tcl interpreter recursively to process
the characters following the open bracket as a Tcl
script. The script may contain any number of commands
and must be terminated by a close bracket
<code>]</code>. The result of the script (i.e. the result
of its last command) is substituted into the word
in place of the brackets and all of the characters
between them. There may be any number of command
substitutions in a single word. Command substitution
is not performed on words enclosed in braces.
<li>If a word contains a dollar-sign <code>$</code> then Tcl
performs variable substitution: the dollar-sign
and the following characters are replaced in the
word by the value of a variable. Variable substitution
may take any of the following forms:
<dl>
<dt><code>$<var>name</var></code>
<dd><var>name</var> is the name of a scalar variable; the name is terminated by any
character that isn't a letter, digit, or underscore.
<br><dt><code>$<var>name</var>(<var>index</var>)</code>
<dd><var>name</var> gives the name of an array variable and <var>index</var> gives the
name of an element within that array. <var>name</var> must contain only letters,
digits, and underscores. Command substitutions, variable substitutions, and
backslash substitutions are performed on the characters of index.
<br><dt><code>${<var>name</var>}</code>
<dd><var>name</var> is the name of a scalar variable. It may contain any characters
whatsoever except for close braces.
</dl>
<p>There may be any number of variable substitutions
in a single word. Variable substitution is not
performed on words enclosed in braces.
</p><li>If a backslash <code>\</code> appears within a word then
backslash substitution occurs. In all cases but
those described below the backslash is dropped and
the following character is treated as an ordinary
character and included in the word. This allows
characters such as double quotes, close brackets,
and dollar signs to be included in words without
triggering special processing. The following table
lists the backslash sequences that are handled specially,
along with the value that replaces each sequence.
<dl>
<dt><code>\a</code>
<dd>Audible alert (bell) (0x7).
<br><dt><code>\b</code>
<dd>Backspace (0x8).
<br><dt><code>\f</code>
<dd>Form feed (0xc).
<br><dt><code>\n</code>
<dd>Newline (0xa).
<br><dt><code>\r</code>
<dd>Carriage-return (0xd).
<br><dt><code>\t</code>
<dd>Tab (0x9).
<br><dt><code>\v</code>
<dd>Vertical tab (0xb).
<br><dt><code>\<newline>whitespace</code>
<dd>A single space character replaces the backslash, newline,
and all spaces and tabs
after the newline. This backslash sequence
is unique in that it is replaced in a separate
pre-pass before the command is actually
parsed. This means that it will be replaced
even when it occurs between braces, and the
resulting space will be treated as a word
separator if it isn't in braces or quotes.
<br><dt><code>\\</code>
<dd>Backslash <code>\</code>.
<br><dt><code>\ooo</code>
<dd>The digits ooo (one, two, or three of them)
give an eight-bit octal value for the Unicode
character that will be inserted. The upper bits
of the Unicode character will be 0.
<br><dt><code>\xhh</code>
<dd>The hexadecimal digits hh give an eight-bit
hexadecimal value for the Unicode character
that will be inserted. Any number of
hexadecimal digits may be present; however, all
but the last two are ignored (the result is
always a one-byte quantity). The upper bits
of the Unicode character will be 0.
<br><dt><code>\uhhhh</code>
<dd>The hexadecimal digits hhhh (one, two,
three, or four of them) give a sixteen-bit
hexadecimal value for the Unicode character
that will be inserted. Backslash substitution is
not performed on words enclosed in braces, except
for backslash-newline as described above.
</dl>
<li>If a hash character <code>#</code> appears at a point
where Tcl is expecting the first character of the
first word of a command, then the hash character
and the characters that follow it, up through the
next newline, are treated as a comment and ignored.
The comment character only has significance when it
appears at the beginning of a command.
<li>Each character is processed exactly once by the Tcl
interpreter as part of creating the words of a command.
For example, if variable substitution occurs
then no further substitutions are performed on the
value of the variable; the value is inserted into
the word verbatim. If command substitution occurs
then the nested command is processed entirely by
the recursive call to the Tcl interpreter; no
substitutions are performed before making the recursive
call and no additional substitutions are performed on
the result of the nested script.
<li>Substitutions do not affect the word boundaries of
a command. For example, during variable substitution
the entire value of the variable becomes part
of a single word, even if the variable's value contains spaces.
</ol>
<p><hr>
Node:<a name="Basics">Basics</a>,
Next:<a rel=next href="#Errors">Errors</a>,
Previous:<a rel=previous href="#Syntax">Syntax</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Basics</h3>
<p>This section gives you a crash course in using Tcl.
Bear in mind that it sins by simplification.
For a precise definition of Tcl's syntax see <a href="#Syntax">Syntax</a>.
For information on the various Tcl commands that are mentioned,
consult the documentation that came with your Tcl installation.
<p>A Tcl script consists of one or more Tcl commands.
A Tcl command has the syntax:
<br><pre><var>cmd</var> <var>arg</var>...
</pre>
<p>Commands are broken up into tokens.
A token is simply a string. White space (spaces or tabs) seperates the
tokens of a command. A command terminates with a newline or semi-colon.
<p>The first token, <var>cmd</var> identifies the command
to be executed. Zero or more <var>arg</var> tokens follow
<var>cmd</var>. They are the arguments to that command. The command
determines what the actual meanings of the arguments are.
<br><pre>echo hello, world
</pre>
<p>The command <code>echo</code> executes with two arguments, <code>hello,</code> and
<code>world</code>.
<p>If a token begins with <code>"</code> or <code>{</code>, the token
contains all the characters up to the next <code>"</code> or <code>}</code> respectively.
This allows a token to include white space. Braces can nest,
double quotes cannot.
<br><pre>echo "hello, world"
</pre>
<p>The command <code>echo</code> executes with one argument, <code>hello, world</code>.
<p>Before a command executes, Tcl performs variable, command, and backslash
substitution on the tokens making up the command. Braces, <code>{}</code>,
prevent the substitutions from being done to the string they enclose.
<p>Variables are created with the <code>set</code> command.
<br><pre>set foo bar
set n 32
</pre>
<p>This creates variables, <code>foo</code>, and <code>n</code> whose
values are <code>bar</code>, and <code>32</code> respectively.
<p>If a token contains a <code>$</code> then the token undergoes variable
substitution. Every occurence of <code>$<var>name</var></code> in a token is replaced
with the variable <var>name</var>'s value.
<br><pre>echo $foo ab$n
</pre>
<p>After substitution the command becomes <code>echo bar ab32</code>.
<p>If a token contains a <code>[</code> then the token undergoes command
substitution. The string beginning with <code>[</code> and and ending
at the next <code>]</code> is evaluated as a Tcl script and becomes the
value returned by the last command in the script. Note that in
this case <code>if</code> is choosing to do command substitution to it's
argument of <code>[string length $str]</code>.
<br><pre>if {[string length $str]} {
echo "$str is not empty, length [string length $str]"
}
</pre>
<p>If the length of <code>$str</code> is not zero, report its length.
Note that the two arguments to <code>if</code> are enclosed by braces.
That means no substitutions are performed on them. The arguments
are simply strings. The command <code>if</code> chooses to evaluate the second
as a script and the first as an expression.
<p>The special interpretation of characters like <code>[</code>,
<code>$</code> can be escaped with <code>\</code>.
<br><pre>echo "\[string length foo\]"
</pre>
<p>This prints <code>[string length foo]</code> to the screen.
<p><hr>
Node:<a name="Errors">Errors</a>,
Next:<a rel=next href="#Arrays">Arrays</a>,
Previous:<a rel=previous href="#Basics">Basics</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Errors</h3>
<p>Scripts stop executing when an error occurs. The global variable
<code>errorInfo</code> is set to a stack trace of the commands leading
up to the error. Errors can be generated with the <code>error</code> command.
Errors can be caught with the command <code>catch</code>.
<p>Example:
<br><pre>proc source2 {file} {
global errorInfo
if {[catch {source $file} ret]} {
echo "Error loading $file: $ret"
echo "Stack trace:"
echo $errorInfo
} else {
return $ret
}
}
</pre>
<p>The command <code>source2</code> tries to source a file. If there
is an error in the file, the error along with a stack trace
is reported.
<br><pre>key set Print {
echo [color "Stack Trace:" bold]
echo $errorInfo
}
</pre>
<p>This creates a key binding that prints out the stack trace of
the last error.
<br><pre>alias set annoy {
if {$1 eq ""} {
error "no target given to annoy"
}
for {set i 0} {$i < 5} {incr i} {
write "smack $1" "spit $1" "kick $1 in the groin"
}
}
</pre>
<p>Create an alias that uses annoying emotes on someone. If
an argument isn't give, the alias aborts with a useful
error message.
<p><hr>
Node:<a name="Arrays">Arrays</a>,
Next:<a rel=next href="#Lists">Lists</a>,
Previous:<a rel=previous href="#Errors">Errors</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Arrays</h3>
<p>Arrays are variables that contain a set of strings.
Those strings are indexed by strings. (Tcl arrays are
implemented internally by hashtables).
<p>Arrays can be created with the <code>set</code> command just
like normal variables.
<br><pre>set arg(first) 3
set arg(2) one
</pre>
<p>This creates an array <code>arg</code> which holds two values,
<code>3</code> and <code>one</code> which are indexed by the strings
<code>first</code> and <code>2</code> respectively.
<p>To access the value of element <var>el</var> of array <var>array</var>
use <code>$<var>array</var>(<var>el</var>)</code>.
<br><pre>echo "first: $arg(first)"
echo "2: $arg(2)"
</pre>
<p>This prints out two indices of array <code>arg</code> and the values associated
with them.
<p>To print out an entire array, <code>array</code>, you would do something like
the following:
<br><pre>foreach index [array names array] {
echo "$index: $array($index)"
}
</pre>
<p><hr>
Node:<a name="Lists">Lists</a>,
Next:<a rel=next href="#New%20commands">New commands</a>,
Previous:<a rel=previous href="#Arrays">Arrays</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Lists</h3>
<p>A Tcl list is a string of tokens separated by white-space.
Every list is a string, but not every string is a list.
The string <code>this is a string</code> is a list consisting of
four elements. The string <code>this {</code> is not. Internally
lists in Tcl are implemented as arrays.
<br><pre>set nums {one two three four five six}
foreach n $nums {
foo $n
}
</pre>
<p>Starting from the first element of the list <code>nums</code>, every element
of the list is assigned to n and the body of the loop evaluated.
<p>Alternately:
<br><pre>set nums {one two three four five six}
for {set i 0} {$i < [llength $nums]} {incr i} {
foo [lindex $nums $i]
}
</pre>
<p>but the first example is more efficient.
<p><hr>
Node:<a name="New%20commands">New commands</a>,
Next:<a rel=next href="#Tips">Tips</a>,
Previous:<a rel=previous href="#Lists">Lists</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>New commands</h3>
<p>New Tcl commands can be created with the command <code>proc</code>.
<br><pre>proc foo {} {
echo foo!
}
</pre>
<p>This creates a command, <code>foo</code>, that prints <code>foo!</code> to the
screen. The command doesn't take any arguments.
<br><pre>proc lastchar {str} {
return [string index $str [expr [string length $str] - 1]]
}
</pre>
<p>This creates a command <code>lastchar</code> which returns the
last character of its argument.
<p>Variables created in procedures have local scope. Variables
created outside procedures have global scope. To access
a global variable from a procedure, use the command <code>global</code>.
<br><pre>set verbose 1
proc laverage {nums} {
global verbose
if {$verbose} {
echo "procedure average called with [llength $nums] numbers"
}
set sum 0
foreach num $nums {
incr sum $num
}
return [expr {$sum / [llength $nums]}]
}
</pre>
<p>The command <code>laverage</code> prints out the number of arguments
given to it, if the global variable <code>verbose</code> is true, and
returns returns the average of the numbers in the list passed
to it.
<p><hr>
Node:<a name="Tips">Tips</a>,
Next:<a rel=next href="#Examples">Examples</a>,
Previous:<a rel=previous href="#New%20commands">New commands</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Tips</h3>
<ol type=1 start=1>
</p><li>To test string equality do not use:
<br><pre>if {$foo == "bar"} {
do something
}
</pre>
<p>use <code>eq</code> like so:
<br><pre>if {$foo eq "bar"} {
do something
}
</pre>
<p>Using <code>eq</code> is faster and avoids some nasty
special cases.
</p><li>If you find yourself using more than a couple
<code>string</code> commands to pick apart a string,
use <code>regexp</code> instead.
<li>Use arrays to group related global variables together.
<li>For the most part treat lists as lists, strings as strings,
and numbers as numbers. Not doing so can often lead to
subtle bugs.
</ol>
<p><hr>
Node:<a name="Examples">Examples</a>,
Previous:<a rel=previous href="#Tips">Tips</a>,
Up:<a rel=up href="#Scripts">Scripts</a>
<br>
<h3>Examples</h3>
<p>Loop from 0 to 9 calling the command <code>foo</code>
with the number of the iteration as an argument.
<br><pre>for {set i 0} {$i < 10} {incr i} {
foo $i
}
</pre>
<p>Alternately:
<br><pre>set i 0
while {$i < 10} {
foo $i
incr i
}
</pre>
<p>Compute the factorial of a number.
<br><pre>proc fac {n} {
for {set res 1} {$n > 1} {incr n -1} {
set res [expr {$n * $res}]
}
return $res
}
</pre>
<p>Return the unique elements of a list.
The order of the elements is lost.
<br><pre>proc luniq {list} {
foreach el $list {
set x($l) ""
}
return [array names x]
}
</pre>
<p><hr>
Node:<a name="Patterns">Patterns</a>,
Next:<a rel=next href="#Procedures">Procedures</a>,
Previous:<a rel=previous href="#Scripts">Scripts</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Patterns</h2>
<p>Many of the commands Mmucl provides take pattern arguments.
The three types of patterns, format, regexp, and glob, used
are described below.
<p>More likely than not the text you will be most interested
in matching will be output from the mud.
<p>Mmucl checks actions and subs against chunks of text sent
from the mud, not line by line. (The config option action_by_line
enables line by line matching for actions.) An action will
be triggered a maximum of one time for a given chunk of text.
A sub will replace its pattern many times in a chunk.
<p>Actions matching occurs before the output is transformed by
the subs. If the config option <code>strip_ansi</code> is true,
the text checked against actions will have ANSI codes removed.
<p>The order in which individual action are matched and individual
substitutions made is dependent on the priorities of those actions and
subs. Priorities are integers and actions or subs with higher priorities are
guaranteed to be operated on before those with lower priority.
<p>Types of patterns:
<ul>
<li><a href="#Format">Format</a>: looks like scanf format
<li><a href="#Regexp">Regexp</a>: regular expressions
<li><a href="#Glob">Glob</a>: glob matching
</ul>
<p><hr>
Node:<a name="Format">Format</a>,
Next:<a rel=next href="#Regexp">Regexp</a>,
Up:<a rel=up href="#Patterns">Patterns</a>
<br>
<h3>Format</h3>
<p>Special characters in a pattern denote a <dfn>match</dfn>.
A <dfn>match</dfn> corresponds to a type of string, such as a number.
<p>Matches:
<dl>
<dt><code>%a</code>
<dd>An ANSI color code.
<br><dt><code>%c</code>
<dd>One character.
<br><dt><code>%d</code>
<dd>A number.
<br><dt><code>%s</code>
<dd>Anything up to the end of a line.
<br><dt><code>%w</code>
<dd>A <dfn>word</dfn>, a contiguous block of anything
that isn't whitespace.
</dl>
<p>Like a match, an <dfn>anchor</dfn> is specially interpreted.
An <dfn>anchor</dfn> forces the pattern to match some location.
<p>Anchors:
<dl>
<dt><code>^</code>
<dd>The beginning of a line.
<br><dt><code>$</code>
<dd>The end of a line.
</dl>
<p>Other characters than anchors or matches in a pattern
are matched exactly.
<p>To disable the special interpretation of a match
prepend <code>%</code> to it. For example, to match a
literal <code>%d</code>, use <code>%%d</code>.
<p>Another special character is <code>*</code>.
It matches anything or nothing. A literal <code>*</code>
can be matched with <code>**</code>.
<p>Finally a <code>|</code>, breaks the pattern into two
branches. Each branch is a pattern. If the
first branch fails to match anything, the second
will be tried. A literal <code>|</code> can be matched
with <code>||</code>.
<p>Literal <code>^</code> and <code>$</code> can be matched with
<code>^^</code> and <code>$$</code> respectively.
<p>A format pattern cannot be malformed. It may not match what
you intend it to, but it will match something.
<p>Examples:
<p><code>%w is here</code> will match <code>dog is here</code>, but
not <code>big dog is here</code>. To match the latter use
<code>%s</code> instead of <code>%w</code>.
<p><code>%s is here|%s are here</code> will match
<code>dog is here</code> or <code>two dogs are here</code>.
<p><hr>
Node:<a name="Regexp">Regexp</a>,
Next:<a rel=next href="#Glob">Glob</a>,
Previous:<a rel=previous href="#Format">Format</a>,
Up:<a rel=up href="#Patterns">Patterns</a>
<br>
<h3>Regexp</h3>
<p>Note that this describes basic regular expressions not the
extended ones present in new versions of Tcl. Read the documentation
that comes with Tcl for a complete explanation.
<p>From the Tcl docs:
<p>A regular expression is zero or more branches, separated
by <code>|</code>. It matches anything that matches one of the
branches.
<p>A branch is zero or more pieces, concatenated. It matches
a match for the first, followed by a match for the second,
etc.
<p>A piece is an atom possibly followed by <code>*</code>, <code>+</code>, or
<code>?</code>. An atom followed by <code>*</code> matches a sequence of 0
or more matches of the atom. An atom followed by <code>+</code>
matches a sequence of 1 or more matches of the atom. An
atom followed by <code>?</code> matches a match of the atom, or the
null string.
<p>An atom is a regular expression in parentheses (matching a
match for the regular expression), a range (see below),
<code>.</code> (matching any single character), <code>^</code> (matching
the null string at the beginning of the input string),
<code>$</code> (matching the null string at the end of the input
string), a <code>\</code> followed by a single character (matching
that character), or a single character with no other
significance (matching that character).
<p>A range is a sequence of characters enclosed in <code>[]</code>.
It normally matches any single character from the
sequence. If the sequence begins with <code>^</code>, it matches
any single character not from the rest of the sequence.
If two characters in the sequence are separated by <code>-</code>,
this is shorthand for the full list of ASCII characters
between them (e.g. <code>[0-9]</code> matches any decimal digit).
To include a literal <code>]</code> in the sequence, make it the
first character (following a possible <code>^</code>). To include
a literal <code>-</code>, make it the first or last character.
<p>Examples:
<p><code>[0-9]+</code> matches an unsigned integer.
<p><code>\-?[0-9]+</code> would match a signed integer.
<p><code>[][\*\(\)\$\^\+\.\?\|\\]</code> matches a special
character in a basic regular expression.
<p>Note that some of the special characters in a
regexp like <code>[</code> or <code>$</code> need to be
hidden from the Tcl parser. To avoid
quoting hell, try to put your regexps in <code>{}</code>.
<p><hr>
Node:<a name="Glob">Glob</a>,
Previous:<a rel=previous href="#Regexp">Regexp</a>,
Up:<a rel=up href="#Patterns">Patterns</a>
<br>
<h3>Glob</h3>
<p>This is the same type of matching used by Tcl's <code>string match</code>
command.
<p>From the Tcl docs:
<p>For the two strings to match, their contents must be identical
except that the following special sequences may appear in pattern:
<dl>
<br><dt><code>*</code>
<dd>Matches any sequence of characters in string, including a null string.
<br><dt><code>?</code>
<dd>Matches any single character in string.
<br><dt><code>[chars]</code>
<dd>Matches any character in the set given by chars. If a sequence of
the form x-y appears in chars, then any character between x and y,
inclusive, will match.
<br><dt><code>\x</code>
<dd>Matches the single character x. This provides a way of avoiding the
special interpretation of the characters <code>*?[]\</code> in pattern.
</dl>
<p>Examples:
<p><code>test*</code> matches anything beginning with <code>test</code>.
<p><code>\*</code> matches <code>*</code>.
<p><hr>
Node:<a name="Procedures">Procedures</a>,
Next:<a rel=next href="#FAQ">FAQ</a>,
Previous:<a rel=previous href="#Patterns">Patterns</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Procedures</h2>
<p>These are commands that Mmucl makes available to the user.
<p>The following shorthand is used to describe the syntax
of the commands. Each argument is one of:
<dl>
<dt><code><var>name</var></code>
<dd>The argument <var>name</var> must be given.
<br><dt><code>[<var>name</var>]</code>
<dd>The argument <var>name</var> is optional.
<br><dt><code>[<var>name</var> <var>value</var>]</code>
<dd>If <var>name</var> is not given, the command treats <var>name</var>
as if it had been given as <var>value</var>.
<br><dt><code>[-<var>switch</var> <var>value</var> -<var>switch</var> --]</code>
<dd>Indicates the command accepts switches.
Switches consist of zero or more arguments preceded by
<code>-</code> and ending with <code>--</code> or an argument that
doesn't begin with <code>-</code>. Some switches take arguments
<br><dt><code><var>name</var>...</code>
<dd>The argument <var>name</var> can occur zero or more times.
</dl>
<p>Commands defined by Mmucl:
<ul>
<li><a href="#action">action</a>: Automatically respond to mud output.
<li><a href="#alias">alias</a>: Shortcuts to Tcl scripts.
<li><a href="#bell">bell</a>: Ring a bell.
<li><a href="#char">char</a>: Manipulate characters.
<li><a href="#check">check</a>: Enforce a given syntax on a command.
<li><a href="#cline">cline</a>: Modify and inspect the command line.
<li><a href="#color">color</a>: Create strings with ANSI codes.
<li><a href="#config">config</a>: Configure various aspects of Mmucl
<li><a href="#connect">connect</a>: Connect to a mud.
<li><a href="#disconnect">disconnect</a>: Disconnect from a mud.
<li><a href="#dump">dump</a>: Save client state to a file.
<li><a href="#echo">echo</a>: Write to the display.
<li><a href="#exit">exit</a>: Quit Mmucl.
<li><a href="#group">group</a>: Manipulate aliases, actions, etc. as one unit.
<li><a href="#help">help</a>: Look at this manual.
<li><a href="#key">key</a>: Bind scripts to keys.
<li><a href="#mmucl">mmucl</a>: Query client status.
<li><a href="#parse">parse</a>: Simulate the command line.
<li><a href="#reconnect">reconnect</a>: Connect to the last mud connected to.
<li><a href="#session">session</a>: Manage multiple Mmucl sessions
<li><a href="#sub">sub</a>: Transform mud output.
<li><a href="#textin">textin</a>: Read a file into the mud.
<li><a href="#write">write</a>: Send strings to the mud.
</ul>
<p><hr>
Node:<a name="action">action</a>,
Next:<a rel=next href="#alias">alias</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>action</h3>
<p>An action consists of a format pattern and a script. When the
pattern matches output from the mud, the script is evaluated.
The script has global scope. See <a href="#Patterns">Patterns</a>, for information
on pattern matching.
<p>Usage: <code>action option arg...</code>
<p>Options:
<dl>
<dt><code>set [-group <var>group</var> -priority <var>priority</var> -<var>type</var> --] <var>pattern</var> [<var>script</var>]</code>
<dd>If <var>script</var> is given create an action. The switch <var>type</var>
indicates what kind of pattern is being set and must be one of
<code>format</code>, <code>exact</code>, or <code>regexp</code>. The default is
<code>format</code>. The <var>priority</var> switch determines the order in which
actions are matched and must be an integer. Higher priority actions
are matched first.
<p>If not, return the script associated with <var>pattern</var>.
<br><dt><code>names [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Return all the action patterns that match <var>glob</var>.
<br><dt><code>delete [-group <var>group</var> -exact --] <var>glob</var></code>
<dd>Delete all the actions that match <var>glob</var>.
The <code>-exact</code> switch forces literal string matching of <var>glob</var>.
<br><dt><code>print [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Print to the display all the actions that match <var>glob</var>.
<br><dt><code>priority [-group <var>group</var> --] <var>pattern</var> [? <var>priority</var>]</code>
<dd>If <var>glob</var> priority is given set the priority of action <var>pattern</var>
to <var>priority</var>. Otherwise return the priority of action <var>pattern</var>.
<br><dt><code>match [-group <var>group</var> --] <var>str</var> [<var>glob</var> *]</code>
<dd>Return a list of all action patterns matching <var>glob</var> that match
<var>str</var>
<br><dt><code>state [-group <var>group</var> --]</code>
<dd>Return a acript that when evaluated will recreate all the actions
in the given group.
</dl>
<p>The switch <var>group</var> always defaults to <code>default</code>.See <a href="#group">group</a>,
for more information.
<p>The script has these global variables available to it:
<dl>
<dt><code>1-9</code>
<dd>The nth match (only those that start with <code>%</code>, counting from the left,
in the action's pattern.
<br><dt><code>0</code>
<dd>The entire string that matched the pattern.
</dl>
<p>Examples:
<br><pre>action set {^%w tells you:} {
write "tell $1 I'm afk. brb"
bell
}
</pre>
<p>Whenever you get a tell, reply that you are afk and ring a bell.
<br><pre>action print *bob*
</pre>
<p>Print out all the actions with <code>bob</code> somewhere in their
pattern.
<br><pre>action set {^Hp: %d(%d)} {
set status(hp) $1
set status(max_hp) $2
}
</pre>
<p>Keep hp and max_hp in the global array status updated for use in other scripts.
<br><pre>action set {^%w grins|^%w bows} {
write "smack $1$2"
}
</pre>
<p>Whenever someone grins or bows, smack them!
<p><hr>
Node:<a name="alias">alias</a>,
Next:<a rel=next href="#bell">bell</a>,
Previous:<a rel=previous href="#action">action</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>alias</h3>
<p>An alias consists of a name and a script. When the first <dfn>word</dfn>,
a block of anything not whitespace, of input matches an alias name,
the script is evaluated.
<p>Usage: <code>alias option arg...</code>
<p>Options:
<dl>
<dt><code>set [-group <var>group</var> --] <var>name</var> [<var>script</var>]</code>
<dd>If <var>script</var> is given create an alias
If <var>script</var> isn't given, return the <var>script</var>
associated with <var>name</var>.
<br><dt><code>names [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Return all the alias names that match <var>glob</var>
<br><dt><code>delete [-group <var>group</var> -exact --] <var>glob</var></code>
<dd>Delete all the aliases that match <var>glob</var>.
The <code>-exact</code> switch forces exact string matching.
<br><dt><code>print [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Print to the display all the aliases that match
<var>glob</var>.
<br><dt><code>state [-group <var>group</var> --]</code>
<dd>Return a acript that when evaluated will recreate all the aliases
in the given group.
</dl>
<p>The switch <var>group</var> always defaults to <code>default</code>.See <a href="#group">group</a>,
for more information.
<p>The script has these global variables available to it:
<dl>
<dt><code>0</code>
<dd>The argument string given to the alias.
<br><dt><code>1-3</code>
<dd>The first three words of the argument string.
</dl>
<p>Examples:
<br><pre>alias set k {write "kill $0"}
</pre>
<p>Send <code>kill</code> followed by any arguments to the mud every
time k is typed.
<br><pre>alias delete *
</pre>
<p>Delete all the defined aliases.
<br><pre>alias delete -exact *
</pre>
<p>Delete the alias <code>*</code>.
<br><pre>alias set sneak {
set dirs {n e w s ne nw se sw}
if {$1} {
foreach dir $dirs {
alias set $dir [list write "sneak $dir"]
}
} else {
foreach dir $dirs {
alias delete -exact -- $dir
}
}
}
</pre>
<p>Set or delete aliases for directions that send
"sneak direction" to the mud.
<br><pre>alias set r {
if {![regexp {^\s*(.*?)\s*(\d+)$} $0 x str num]} {
set str $0
set num 1
}
for {set i 0} {$i < $num} {incr i} {
write $str
}
}
</pre>
<p>Find a number at the end of the argument string. Write everything
up to that number, except buffering white-space, to the mud
that number times.
<p><hr>
Node:<a name="bell">bell</a>,
Next:<a rel=next href="#char">char</a>,
Previous:<a rel=previous href="#alias">alias</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>bell</h3>
<p>Ring a bell.
<p>Usage: <code>bell</code>
<p>Examples:
<br><pre>key set Control-g bell
</pre>
<p>Ring the bell every time <kbd>Control-g</kbd> is pressed.
<p><hr>
Node:<a name="char">char</a>,
Next:<a rel=next href="#check">check</a>,
Previous:<a rel=previous href="#bell">bell</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>char</h3>
<p>A char stores information about a character on a mud.
Mmucl saves the information on exit and restores it
on startup. Each character has an init file in <code>~/.mmucl2/chars</code>.
<p>Usage: <code>char option arg...</code>
<p>Options:
<dl>
<dt><code>set <var>name</var> [<var>info</var>]</code>
<dd>
The argument <var>info</var> is a list of the form
{<var>host</var> <var>port</var> <var>login</var>}.
The element <var>login</var> s itself a list and need not be present.
<p>If <var>info</var> is given, define a character.
An init file, <var>name</var>, will be created in
<code>~/.mmucl2/chars</code>.
Otherwise return the <var>info</var> associated with <var>name</var>.
<br><dt><code>names [<var>glob</var> *]</code>
<dd>Return all the char names that match <var>glob</var>
<br><dt><code>delete -- <var>glob</var></code>
<dd>Delete all the chars that match <var>glob</var>.
The <code>-exact</code> switch forces exact string matching.
<br><dt><code>print [<var>glob</var> *]</code>
<dd>Print to the display all the chars that match <var>glob</var>.
<br><dt><code>load <var>name</var></code>
<dd>Connect to <var>name</var>'s mud, load <var>name</var>'s init file,
and write each element of <var>login</var> to the mud.
</dl>
<p>Examples:
<br><pre>char set Arithon {dracos.ptn.net 3000 {arithon passwd}}
</pre>
<p>On connection to the mud, <code>arithon</code> and then <code>passwd</code>
will be sent. You may want to make sure <code>~/.mmucl2</code> where
the character information is stored readable only by you.
The login list is stored as plain text.
<br><pre>char set Arithon {dracos.ptn.net 3000}
</pre>
<p>Just like the above except nothing in sent to the mud
on connect.
<p><hr>
Node:<a name="check">check</a>,
Next:<a rel=next href="#cline">cline</a>,
Previous:<a rel=previous href="#char">char</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>check</h3>
<p>Do argument handling for a procedure.
<p>Usage: <code>check [-opts --] <var>name</var> <var>syntax</var> <var>arglist</var></code>
<p>If the switch <code>-opts</code> is given, then the command has
options (subcommands) and <var>syntax</var> is a list of the
form {(<var>option</var> <var>spec</var>)...}.
Otherwise <var>syntax</var> is a list of the form
{<var>spec</var>}.
<p>Each spec indicates a type of argument the command takes
and is a list of the form:
<dl>
<br><dt><code>{+ <var>name</var>}</code>
<dd>The argument <var>name</var> must be given.
<br><dt><code>{? <var>name</var>}</code>
<dd>The argument <var>name</var> is optional.
<br><dt><code>{? <var>name</var> <var>default</var>}</code>
<dd>The argument <var>name</var> is optional
and becomes <var>default</var> if not given.
<br><dt><code>{- <var>name</var> {<var>name2</var> <var>value</var>}...}</code>
<dd>The command takes a <var>name</var> switch and a <var>name2</var> switch that
takes an argument and defaults to <var>value</var>.
</dl>
<p>The arguments are checked against <var>syntax</var> and
check aborts with an appropriate error message if they
do not match the syntax.
<p>If the syntax of the arguments is correct, the
arguments are made available to the calling block
of code in the array <code>arg</code> indexed by <var>name</var>.
Switches will be 1 if given, and 0 if not.
<p>Examples:
<br><pre>proc rand {args} {
set syntax {
seed {{? seed}}
get_int {{+ range} {? min 0} }
get_float {{+ range} {? min 0}}
}
switch -exact -- [check -opts rand $syntax $args] {
seed {
if {[info exists arg(seed)]} {
expr {srand($arg(seed))}
} else {
expr {srand([clock clicks])}
}
} get_int {
return [expr {int(rand() * $arg(range)) + $arg(min)}]
} get_float {
return [expr {rand() * $arg(range) + $arg(min)}]
}
}
return
}
</pre>
<p>This creates a command <code>rand</code> that has subcommands,
<code>seed</code>, <code>get_int</code>, and <code>get_float</code>.
<p><hr>
Node:<a name="cline">cline</a>,
Next:<a rel=next href="#color">color</a>,
Previous:<a rel=previous href="#check">check</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>cline</h3>
<p>Modify the current command line. Only the graphical interfaces
completely implement this function.
<p>Usage: <code>cline option arg...</code>
<p>Options:
<dl>
<br><dt><code>delete [<var>index1</var> 0] [<var>index2</var> end]</code>
<dd>Delete the text from <var>index1</var> to <var>index2</var>.
<br><dt><code>get [<var>index1</var> 0] [<var>index2</var> end]</code>
<dd>Return the command line from <var>index1</var> to <var>index2</var>.
<br><dt><code>insert <var>index</var> <var>string</var></code>
<dd>Insert <var>string</var> into the command line at <var>index</var>.
<br><dt><code>history</code>
<dd>Return a list of the last config option <code>hist_keep</code> commands
typed.
<br><dt><code>hide [<var>bool</var> 1]</code>
<dd>Toggle hiding command line input.
</dl>
<p>Index:
<dl>
<dt><code>n</code>
<dd>The nth character.
<br><dt><code>insert</code>
<dd>The location of the insertion cursor.
<br><dt><code>end</code>
<dd>The last character.
</dl>
<p>Examples:
<br><pre>key set Control-u {cline delete 0 insert}
</pre>
<p>Delete the current line when <kbd>Control-x</kbd> is hit.
<p><hr>
Node:<a name="color">color</a>,
Next:<a rel=next href="#config">config</a>,
Previous:<a rel=previous href="#cline">cline</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>color</h3>
<p>Return a string with ansi text attributes.
<p>Usage: <code>color (<var>str</var> <var>attribs</var>)...</code>
<p>Colors: black, red, green, yellow, brown, blue, magenta,
cyan, and white.
<p>All of the text attributes below and the colors listed above may or may
not be supported by whatever console the text is displayed in.
<p>The argument <var>attribs</var> is a list made up of these text attributes:
<dl>
<br><dt><code>reset</code>
<dd>Reset the terminal to its defaults.
<br><dt><code>bold</code>
<dd>Bold font.
<br><dt><code>dim</code>
<dd>Make the text dim.
<br><dt><code>underline</code>
<dd>Underline the text.
<br><dt><code>blink</code>
<dd>Flash the text.
<br><dt><code>reverse</code>
<dd>Reverse foreground and background
<br><dt><code><var>color</var></code>
<dd>Set the foreground to one of the colors listed above.
<br><dt><code>bg_<var>color</var></code>
<dd>Set the background to one of the colors listed above.
</dl>
<p>The string returned will always end with the attributes
given by the config option <code>end_color</code>.
<p>Examples:
<br><pre>echo [color WARNING!! {bold red}]
</pre>
<p>Display "WARNING!!" in bold font with a red foreground.
<br><pre>color r red a green i yellow n blue b white o cyan w magenta
</pre>
<p>Return <code>rainbow</code> with ansi codes to set each character
to a different color.
<p><hr>
Node:<a name="config">config</a>,
Next:<a rel=next href="#connect">connect</a>,
Previous:<a rel=previous href="#color">color</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>config</h3>
<p>Change and inspect Mmucl config options.
<p>Usage: <code>config option arg...</code>
<p>Options:
<dl>
<dt><code>set <var>option</var> [<var>value</var>]</code>
<dd>If <var>option</var> is given, set <var>option</var> to <var>value</var>.
Otherwise return <var>option</var>'s value.
<br><dt><code>names [<var>glob</var> *]</code>
<dd>Return all the options that match <var>glob</var>
<br><dt><code>print [<var>glob</var>]</code>
<dd>Print to the display all the options that match <var>glob</var>.
</dl>
<p>Options
<dl>
<br><dt><code>action_by_line</code>
<dd>If true, check actions against every line of text.
Otherwise, check actions against every chunk of text.
<br><dt><code>actions</code>
<dd>Check actions?
<br><dt><code>echo</code>
<dd>Echo command line?
<br><dt><code>echo_color</code>
<dd>A list of text attributes applied to echos of the command line.
<br><dt><code>error_color</code>
<dd>List of text attributes applied to error messages.
<br><dt><code>hist_keep</code>
<dd>Number of commands kept in history.
<br><dt><code>hist_min</code>
<dd>Minimum length of input to be stored in history.
<br><dt><code>keep_line</code>
<dd>Delete the command line after enter?
<br><dt><code>print_color</code>
<dd>List of text attribues applied to text printed by Mmucl.
<br><dt><code>report_color</code>
<dd>List of text attribues applied to events reported by Mmucl.
<br><dt><code>reconnect</code>
<dd>Number of times to try connecting to a host after timeouts.
<br><dt><code>script_char</code>
<dd>Character at beginning of input that indicates
the rest of the line is a Tcl script.
<br><dt><code>split_char</code>
<dd>Character command line input is split on.
<br><dt><code>strip_ansi</code>
<dd>Strip out ansi codes?
(This only occurs for action matching.)
<br><dt><code>subs</code>
<dd>Check subs?
<br><dt><code>timeout</code>
<dd>Number of seconds to wait for a connection.
<br><dt><code>use_mccp</code>
<dd>Attempt to load support for the MCCP protocol via the Tcl_MCCP extension,
<a href="http://tcl-mccp.sourceforge.net/">http://tcl-mccp.sourceforge.net/</a>.
<br><dt><code>use_threads</code>
<dd>Try to load the Tcl Thread extension available from
<a href="http://tcl.sourceforge.net">http://tcl.sourceforge.net</a>. If loaded, Mmucl will use threads
to do asynchronous host lookups.
<br><dt><code>verbatim_char</code>
<dd>Character at beginning of input that indicates
the rest of the line should be sent to the mud
as is.
</dl>
<p>Examples:
<br><pre>config print *_color
</pre>
<p>Print out all the config options that set a color.
<br><pre>config set script_char #
</pre>
<p>Scripts typed at the command line now must begin with <code>#</code>.
<p><hr>
Node:<a name="connect">connect</a>,
Next:<a rel=next href="#disconnect">disconnect</a>,
Previous:<a rel=previous href="#config">config</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>connect</h3>
<p>Connect to a mud.
<p>Usage: <code>connect <var>host</var> <var>port</var> [<var>login</var> {}]</code>
<p>Connect to <var>host</var> at <var>port</var>. Each element of the list
<var>login</var> is written to the mud on a successful connection. The config
option <code>timeout</code> determines how long <code>connect</code> waits for
a response. If the connection attempt times out, Mmucl will try
reconnecting the number of times the config option <code>reconnect</code>
is set to.
<p>Examples:
<br><pre>connect mud.domain 2000 {name passwd 1}
</pre>
<p>Try to connect to the mud running at mud.domain on port 2000.
If we connect write <code>name</code>, <code>passwd</code>, and then <code>1</code>
to the mud.
<br><pre>connect dracos.ptn.net 3000
</pre>
<p>Try to connect to the mud running at dracos.ptn.net on port 3000.
<p><hr>
Node:<a name="disconnect">disconnect</a>,
Next:<a rel=next href="#dump">dump</a>,
Previous:<a rel=previous href="#connect">connect</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>disconnect</h3>
<p>Disconnect ends a connection to a mud and will also stop an
attempted connection.
<p>Usage: <code>disconnect</code>
<p>Examples:
<br><pre>key set Escape disconnect
</pre>
<p>Set up a key binding to disconnect.
<p><hr>
Node:<a name="dump">dump</a>,
Next:<a rel=next href="#echo">echo</a>,
Previous:<a rel=previous href="#disconnect">disconnect</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>dump</h3>
<p>The command <code>dump</code> can save to a file the data created by the
commands <code>action</code>, <code>alias</code>,
<code>char</code>, <code>config</code>, <code>key</code>, and <code>sub</code>. Procedures
and variables can also be saved.
The data can then be recreated by loading the file produced with
the command <code>source</code>.
<p>Syntax: <code>dump -- <var>file</var></code>
<p>Switches:
<dl>
<dt><code>-<var>cmd</var></code>
<dd>Select <var>cmd</var> to save.
<br><dt><code>-<code>group</code> <var>value</var></code>
<dd>Save only data in group <var>value</var>. This defaults to <code>default</code>.
See See <a href="#group">group</a>, for more info.
<br><dt><code>-append</code>
<dd>Write to the end of <var>file</var>
<br><dt><code>-proc</code>
<dd>Write out all procedures in the global namespace.
Note that this will also dump out internal procedures that Tcl defines.
<br><dt><code>-var</code>
<dd>Write out all variables in the global namespace.
</dl>
<p>By default everything is dumped.
<p>Examples:
<br><pre>dump -alias -- aliases
</pre>
<p>Write all the currently defined aliases to the file <code>aliases</code>.
<br><pre>proc exit_save {} {
dump -- [file join [mmucl rc_dir] save]
exit
}
</pre>
<p>Create a command <code>save_exit</code> that saves everything to the
file <code>~/.mmucl2/save</code> and then exits.
On startup you could load everything back in
with by putting <code>source [file join $env(HOME) .mmucl2 save]</code>
in your <code>mmucl.rc</code>.
<p><hr>
Node:<a name="echo">echo</a>,
Next:<a rel=next href="#exit">exit</a>,
Previous:<a rel=previous href="#dump">dump</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>echo</h3>
<p>Write to the display.
<p>Usage <code>echo <var>str</var>...</code>
<p>Echo joins all the <var>str</var>'s into a single string with
a space inbetween each <var>str</var>, appends a newline to the end,
and writes the result to the display.
<p>Examples:
<br><pre>echo "foo bar"
echo foo bar
</pre>
<p>The result is the same for each <code>echo</code>.
<br><pre>echo [color "It's Christmas!" {bold red bg_green}]
</pre>
<p>Print "It's Christmas" in bold red with a green
background.
<br><pre>proc minfo {} {
global env tcl_platform tcl_version tk_version
echo "Host: [info hostname]"
echo "OS: $tcl_platform(os) $tcl_platform(osVersion)"
echo "Tcl version: $tcl_version"
catch {echo "Tk version: $tk_version"}
echo "Home directory: $env(HOME)"
echo
echo Aliases: [llength [alias names]]
echo Actions: [llength [action names]]
echo Subs: [llength [sub names]]
echo Keys: [llength [key names]]
echo Chars: [llength [char names]]
}
</pre>
<p>Define a command <code>minfo</code> that print out miscellaneous info about
the system Mmucl is running on and the user interp.
<p><hr>
Node:<a name="exit">exit</a>,
Next:<a rel=next href="#group">group</a>,
Previous:<a rel=previous href="#echo">echo</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>exit</h3>
<p>Log on to that strange place known as real life.
<p>Usage: <code>exit</code>
<p>Exit also saves any chars defined as well as all the
config options so that they can be restored on startup.
<p><hr>
Node:<a name="group">group</a>,
Next:<a rel=next href="#help">help</a>,
Previous:<a rel=previous href="#exit">exit</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>group</h3>
<p>A group is a set of aliases, actions, keys, and subs that can be
manipulated as one unit. Groups can be created, and there members
manipulated, by using one of the
above <code><var>type</var> set</code> commands and passing in <code>-group <var>name</var></code>.
<p>The default group, <code>default</code>, cannot be
deleted. Members in a group can have the same name as the equivalent
type in another group. For example if two aliases in different groups
share the same name, that name will trigger the evaluation of both aliases.
<p>Usage: <code>group option arg...</code>
<p>Options:
<dl>
<dt><code>names [<var>glob</var> *]</code>
<dd>Return all the group names that match <var>glob</var>
<br><dt><code>delete -- <var>glob</var></code>
<dd>Delete all the groups that match <var>glob</var>.
The <code>-exact</code> switch forces exact string matching.
<br><dt><code>print [<var>glob</var> *]</code>
<dd>Print to the display all the groups that match <var>glob</var>.
</dl>
<p>Examples:
<br><pre> key set -group capture Key {
append mud_text [cline get]
}
action set -group capture * {
append mud_text $0
}
}
</pre>
<p>Creates a <code>capture</code> group with two members that append all mud
output and user input to the end of the global variable
<code>mud_text</code>. By putting these in their own group we can define
other actions and keys with the same pattern or key event in other
groups and have all of them be triggered as appropriate.
<p><hr>
Node:<a name="help">help</a>,
Next:<a rel=next href="#key">key</a>,
Previous:<a rel=previous href="#group">group</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>help</h3>
<p>Start an info browser to read Mmucl's info file.
<p>Usage: <code>help [<var>subject</var>]</code>
<p>If <var>subject</var> is given go to node <var>subject</var>.
Otherwise go to the Top node. Note that this may be an empty stub in
some interfaces.
<p>Examples:
<br><pre>help help
</pre>
<p>Go to this node.
<p><hr>
Node:<a name="key">key</a>,
Next:<a rel=next href="#mmucl">mmucl</a>,
Previous:<a rel=previous href="#help">help</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>key</h3>
<p>A key consists of an event and a script.
When a sequence of keys matches an event,
the script is evaluated. The script has global scope.
Note that this may be an empty stub in the text interfaces.
<p>Much of the information in this section was taken
from the Tk documentation on the command <code>bind</code>.
<p>Usage: <code>key option arg...</code>
<p>Options:
<dl>
<dt><code>set [-group <var>group</var> --] <var>key</var> [<var>script</var>]</code>
<dd>
If <var>script</var> is given, create a key.
Otherwise return the script bound to <var>key</var>.
<br><dt><code>names [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Return all the key names that match <var>glob</var>
<br><dt><code>delete [-group <var>group</var> --] -- [<var>glob</var> *]</code>
<dd>Delete all the keys that match <var>glob</var>.
The <code>-exact</code> switch forces literal string matching
of <var>glob</var>.
<br><dt><code>print [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Print to the display all the keys that match <var>glob</var>.
<br><dt><code>current</code>
<dd>Return the last key event that occurred.
<br><dt><code>state [-group <var>group</var> --]</code>
<dd>Return a acript that when evaluated will recreate all the keys
in the given group.
</dl>
<p>The switch <var>group</var> always defaults to <code>default</code>.See <a href="#group">group</a>,
for more information.
<p>Key events describe a sequence of key presses.
Each event pattern may take one of two forms.
In the simplest case it is a single printing ASCII character,
such as <code>a</code> or <code>[</code>. The character may not be a space
character or the character <code><</code>. This form of pattern
matches a key press for the particular character.
<p>The second form of pattern is <code>modifier-keysym</code>.
This form of pattern matches a key being hit, the keysym, while
another is being held, the modifier. There may be more than one modifier
separated by <code>-</code>.
<p>Modifiers:
<dl>
<dt><code>Control</code>
<br><dt><code>Shift</code>
<br><dt><code>Alt</code>
<br><dt><code>Mod<var>x</var></code>
<dd>where <var>x</var> ranges from <code>1</code> to <code>5</code>.
</dl>
<p>Keysyms are textual specifications for particular keys on the keyboard;
they include all the alphanumeric ASCII characters
(e.g. <code>a</code> is the keysym for the ASCII character <code>a</code>),
plus descriptions for non-alphanumeric characters
(<code>comma</code> is the keysym for the comma character), plus
descriptions for all the non-ASCII keys on the keyboard
(<code>Shift_L</code> is the keysym for the left shift key, and
<code>F1</code> is the keysym for the <code>F1</code> function key, if it
exists). The complete list of keysyms may vary from system to
system. The special keysym <code>Key</code> matches any key being pressed.
As shown below, it can be used with <code>key current</code> to see all
the keysyms available.
<p>If a script terminates with the command <code>break</code>, then no
further scripts that match the event are evaluated. This can
be used to ignore the built in bindings which are checked after
user defined bindings.
<p>Examples:
<br><pre>key set Key {echo [key current]}
</pre>
<p>Print out key events as they occur.
<br><pre>key set Escape {write flee}
</pre>
<p>Send "flee" to the mud when <kbd>Escape</kbd> is hit.
<br><pre>key set a break
</pre>
<p>Prevent the key a from causing <code>a</code> to be inserted in the input entry.
Now how do you about removing this key binding?
<p><hr>
Node:<a name="mmucl">mmucl</a>,
Next:<a rel=next href="#parse">parse</a>,
Previous:<a rel=previous href="#key">key</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>mmucl</h3>
<p>Query various information about the client.
<p>Usage: <code>mmucl option arg...</code>
<p>Options:
<dl>
<dt><code>lib_dir</code>
<dd>Return directory where Mmucl was installed.
<br><dt><code>rc_dir</code>
<dd>Return directory where user config files are kept.
<br><dt><code>host</code>
<dd>Return last host connected to or an empty string.
<br><dt><code>port</code>
<dd>Return port of last host connected to or an empty string.
<br><dt><code>version</code>
<dd>Return Mmucl version.
<br><dt><code>connect</code>
<dd>Return a bool indicating connection status.
<br><dt><code>interface</code>
<dd>Return interface being used.
</dl>
<p>Examples:
<br><pre>glob --nocomplain -directory [file join [mmucl rc_dir] chars] *
</pre>
<p>Get a list of all the character config files.
<p><hr>
Node:<a name="parse">parse</a>,
Next:<a rel=next href="#reconnect">reconnect</a>,
Previous:<a rel=previous href="#mmucl">mmucl</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>parse</h3>
<p>Interpret a string just as if you'd typed it in.
<p>Usage: <code>parse <var>str</var></code>
<p>If <var>str</var> begins with the config option <code>verbatim_char</code>,
by default <code>\</code>, send <var>str</var>, minus <code>verbatim_char</code>,
to the mud.
<p>If <var>str</var> begines with the config option <code>script_char</code>,
by default <code>/</code>, <var>str</var>, minus <code>script_char</code>, is
evaluated as a Tcl script.
<p>Barring the first two cases, <var>str</var> is split up into a sequence of
substringss delimited by the config option <code>split_char</code>, by default
<code>;</code>. If the first word of a substring matches
an alias, the alias is executed. Otherwise the substring is sent to the
mud.
<p>Examples:
<br><pre>alias set . {
parse [lindex [cline history] end]
}
</pre>
<p>Reparse the last command added to history.
This is too simplistic. If <code>.</code> was
added to the history list, using it again
would cause an infinite loop!
<br><pre>proc al {name cmd} {
alias set $name [list parse $cmd]
}
</pre>
<p>Define a new command <code>al</code> that creates
an alias <code>name</code>. When invoked <code>name</code> acts
as if <code>cmd</code> had been typed instead.
<p><hr>
Node:<a name="reconnect">reconnect</a>,
Next:<a rel=next href="#session">session</a>,
Previous:<a rel=previous href="#parse">parse</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>reconnect</h3>
<p>Attempt to resume the last connection.
<p>Usage: <code>reconnect</code>
<p>If a login was given on the last connect, it will
be sent again.
<p>Examples:
<br><pre>key set F12 reconnect
</pre>
<p>Try to reconnect every time F12 is pressed.
<p><hr>
Node:<a name="session">session</a>,
Next:<a rel=next href="#sub">sub</a>,
Previous:<a rel=previous href="#reconnect">reconnect</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>session</h3>
<p>A session is the environment all interaction with Mmucl occurs
through. That environment encapsulates all user defined data such as
procedures, variables, aliases, and actions. There are a few
exception. Config options and characters are shared between all sessions.
Sessions can communicate only through <code>session eval</code>.
<p>Starting Mmucl automatically creates a default session. New sessions can
be created with <code>session new</code>. Each session has a numerical id with
which it can be manipulated. Only one session is current at a given
time. That session receives all user input and typically, unless
snooped, only output from that session is displayed. The current session may be
changed with <code>session switch</code>.
<p>The primary purpose of sessions is to allow playing several muds
simultaneously. Each session can be connected to one mud.
<p>Usage: <code>session option arg...</code>
<p>Options:
<dl>
<dt><code>new</code>
<dd>Create a new session, switch to it, and return the id.
<br><dt><code>names</code>
<dd>Return a list of all session ids.
<br><dt><code>eval <var>id</var> <var>script</var></code>
<dd>Evaluate <var>script</var> in session <var>id</var> and return the result.
<br><dt><code>switch <var>id</var></code>
<dd>Make session <var>id</var> current.
<br><dt><code>snoop <var>id</var> [<var>bool</var> true]</code>
<dd>Set whether or not session <var>id</var> is snooped. A snooped session has
its output displayed even when it is not current.
<br><dt><code>current</code>
<dd>Return the id of the current session.
<br><dt><code>close <var>id</var></code>
<dd>End session <var>id</var>.
<br><dt><code>print</code>
<dd>Print info about all sessions to the display.
</dl>
<p><hr>
Node:<a name="sub">sub</a>,
Next:<a rel=next href="#textin">textin</a>,
Previous:<a rel=previous href="#session">session</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>sub</h3>
<p>A sub consists of a format pattern and a subspec.
The sub replaces every occurence of its pattern in mud
output with its subspec. See <a href="#Patterns">Patterns</a>, for information on pattern matching.
<p>Usage: <code>sub option arg...</code>
<p>Options:
<dl>
<dt><code>set [-group <var>group</var> -priority <var>priority</var> -<var>type</var> --]</code>
<dd><var>pattern</var> [<var>subspec</var>]
<p>If <var>subspec</var> is given create a sub. The switch <var>type</var>
indicates what kind of pattern is being set and must be one of
<code>format</code>, <code>exact</code>, or <code>regexp</code>. The default is
<code>format</code>. The <var>priority</var> switch determines the order in which
subs are matched and must be an integer. Higher priority actions
are matched first.
<p>If not, return the subspec associated with <var>pattern</var>.
<br><dt><code>names [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Return all the sub names that match <var>glob</var>.
<br><dt><code>delete [-group <var>group</var> -exact --] <var>glob</var></code>
<dd>Delete all the sub that match <var>glob</var>.
The switch <code>-exact</code> forces literal string
matching of <var>glob</var>.
<br><dt><code>print [-group <var>group</var> --] [<var>glob</var> *]</code>
<dd>Print to the display all the subs that match <var>glob</var>.
<br><dt><code>priority [-group <var>group</var> --] <var>pattern</var> [? <var>priority</var>]</code>
<dd>If <var>glob</var> priority is given set the priority of sub <var>pattern</var>
to <var>priority</var>. Otherwise return the priority of sub <var>pattern</var>.
<br><dt><code>match [-group <var>group</var> --] <var>str</var> [<var>glob</var> *]</code>
<dd>Return a list of all sub patterns matching <var>glob</var> that match
<var>str</var>
<br><dt><code>state [-group <var>group</var> --]</code>
<dd>Return a acript that when evaluated will recreate all the subs
in the given group.
</dl>
<p>While replacing a pattern with a subspec
the following substitutions in <var>subspec</var> are
done:
<dl>
<dt><code>\n</code>
<dd>The nth match of the pattern.
<br><dt><code>\0</code>
<dd>The whole string matched.
<br><dt><code>&</code>
<dd>The whole string matched.
<br><dt><code>\\</code>
<dd>\
<br><dt><code>\&</code>
<dd>&
</dl>
<p>If the subsepc has backslashes, you'll like want to protect
it from Tcl's interpretation of backslashes by putting
it in braces, <code>{}</code>.
<p>Examples:
<br><pre>sub set "^%w tells you: %s" {"\2", says \1}
</pre>
<p>Change <code>Renir tells you: heheh</code> to <code>"heheh", says Renir</code>.
<br><pre>sub set Arithon [color & {bold magenta}]
</pre>
<p>Change <code>Arithon</code>'s color to be bold magenta.
<br><pre>proc gag {name} {
sub set -group gag -- ^%s$name%s ""
}
proc ungag {name} {
sub delete -group gag -exact -- ^%s$name%s
}
</pre>
<p>Define two commands, <code>gag</code> and <code>ungag</code> that
respectively set a gag on <code>name</code>, deleting
every line with <code>name</code> in it, or remove a
gag on <code>name</code>. This isn't completely correct.
completely correct. To make sure you match <code>name</code>,
you'd have to escape any format patterns in <code>name</code>.
<p><hr>
Node:<a name="textin">textin</a>,
Next:<a rel=next href="#write">write</a>,
Previous:<a rel=previous href="#sub">sub</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>textin</h3>
<p>Send a file to the mud.
<p>Usage: <code>textin <var>file</var></code>
<p>Textin writes <var>file</var> to the mud.
<p>Examples:
<br><pre>alias set postfile {
write "post file: $1"
textin $1
write .
}
</pre>
<p>Create an alias <code>postfile</code> that, on
RoD anyway, posts a file to a message board.
<p><hr>
Node:<a name="write">write</a>,
Previous:<a rel=previous href="#textin">textin</a>,
Up:<a rel=up href="#Procedures">Procedures</a>
<br>
<h3>write</h3>
<p>Send strings to the mud.
<p>Usage: <code>write <var>str</var>...</code>
<p>Send each <var>str</var> to the mud.
<p>Examples:
<br><pre>write "get all from corpses"
write "bury all"
</pre>
<p>The above is the same as:
<br><pre>write "get all from corpses" "bury all"
</pre>
<p><hr>
Node:<a name="FAQ">FAQ</a>,
Next:<a rel=next href="#Feedback">Feedback</a>,
Previous:<a rel=previous href="#Procedures">Procedures</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>FAQ</h2>
<ol type=1 start=1>
</p><li>How do I access a global variable from an alias?
<p>Aliases scripts have global scope. Variables created
in an alias are global, but variables created in a procedure are by
default local. For more information
see the Tcl docs on <code>global</code> and <code>namespace</code>.
<br><pre>set gvar test
alias set foo {
echo $gvar
}
</pre>
<p>The alias prints out test.
<br><pre>proc foo {} {
global gvar
set gvar test2
return $gvar
}
</pre>
<p>The procedure sets and returns the value of the global variable <code>gvar</code>.
</p><li>How do I get Mmucl working in Windows?
<p>Follow the directions in the file <code>INSTALL</code>.
</p><li>How do I highlight mud output?
<p>You have to insert ansi codes to do the colors with a
sub. A string with ansi colors can be created with the
color command.
<br><pre>proc highlight {format colors} {
sub set $format [color & $colors]
}
</pre>
<p>This highlight procedure will add a list of colors
a the format pattern. Read about the <a href="#color">color</a> command
to see what text attributes are supported.
</p><li>Does Mmucl have speedwalk?
<p>Not builtin, but it can be added easily.
Look at the sample mmucl.rc for one implementation.
</p><li>How do I move with the keypad?
<p>You have to use the key command to bind scripts
to the keypad. Look at the move command in the
sample mmucl.rc for an example.
</p><li>How do I prevent keys I bind to events from doing other things?
<p>Keys may do other things than just what you bind them to.
To prevent a key from doing anything but what its bound
to, have the script break.
<p>key set a break
<p>This prevents <kbd>a</kbd> from appearing in the input widget when
the key <kbd>a</kbd> is hit.
<br><pre>key set KP_Add {write up; break}
</pre>
<p>Send "up" to the mud when the plus in the keypad is hit and
don't print a plus on the input entry.
</p><li>How do I match the beginning of a line in a rxp_action?
<p>Remember you are matching a chunk of text. The beginning of
a line is either preceded by a newline or by nothing.
<br><pre>rxp_action set "(^|\n)Beg of a line" {echo Whee!}
</pre>
<p>If you are in action_by_line mode then just "^Beg of a line" will work.
Alternately enable <code>-line</code> mode in the regexp with
<code>(?n)^Beg of line</code>.
</ol>
<p><hr>
Node:<a name="Feedback">Feedback</a>,
Previous:<a rel=previous href="#FAQ">FAQ</a>,
Up:<a rel=up href="#Top">Top</a>
<br>
<h2>Feedback</h2>
<p>If you have comments, ideas, or suggestions, I'd be
interested in hearing them. Bear in mind that I'm
only interested in adding features that cannot be
implemented in the user interp. Take a look through
the manual to see if Mmucl already provides the functionality
to implement what you want.
<p>For bug reports I need to know your Mmucl version,
Tcl/Tk version, operating system, and, if relevant,
the address of the mud you are having a problem on.
<p>Mail feedback to <a href="mailto:msp@users.sourceforge.net">msp@users.sourceforge.net</a> and please
put <code>Mmucl</code> somewhere on the subject line.
Alternately fill out a bug report on the Sourceforge
project page, <a href="http://sourceforge.net/projects/mmucl">http://sourceforge.net/projects/mmucl</a>
</body></html>
|