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 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<!-- $Id: kildclient.xml,v 1.102 2006/08/10 14:49:24 ekalin Exp $ -->
<book>
<bookinfo>
<title>KildClient Manual</title>
<subtitle>Version 2.5.0</subtitle>
<author>
<firstname>Eduardo</firstname>
<othername>M</othername>
<surname>Kalinowski</surname>
</author>
<copyright>
<year>2004-2006</year><holder>Eduardo M Kalinowski</holder>
</copyright>
</bookinfo>
<part><title>KildClient User's Guide</title>
<chapter><title>Introduction</title>
<para>KildClient is a MUD Client written with the GTK+ windowing
toolkit. It supports many common features of other clients, such as
triggers, gags, aliases, macros, timers, and much more. But its main
feature is the built-in Perl interpreter. You can at any moment
execute Perl statements and functions to do things much more powerful
than simply sending text the the mud. Perl statements can also be run,
for example, as the action of a trigger, allowing you to do complex
things. Some built-in functions of KildClient allow interaction with
the world, such as sending commands to it.</para>
<para>This manual will guide you in using KildClient. First the basic
usage will be described, and then more advanced features will be
explained. In the end, there is a reference of all built-in functions
of KildClient, which can be called from your scripts.</para>
<para>It is assumed that the user has some basic knowledge of MUDs and
their working, and also of the specific MUDs the users connects to.
This manual has no aim at explaining how to play a MUD. Even when
specific examples are given of commands, these might not work on all
MUDs.</para>
</chapter>
<chapter id="chap:running"><title>Running KildClient</title>
<para>To run KildClient, type <command>kildclient</command> in your
command prompt:</para>
<cmdsynopsis><command>kildclient [-c DIR] [World...] &</command></cmdsynopsis>
<para>The ampersand (&) at the end of the line means that the
command is to be executed in background, that is, not to wait until it
finishes to get another command prompt. Since KildClient is a GUI
program that does not require any input from the terminal, this is the
desired behaviour.</para>
<para>You can enter the name of one or more saved Worlds in the
command line, to have these Worlds opened automatically. If the World
name contains spaces, you will need to quote it to prevent it from
being interpreted as two or more names. The exact way depends on your
shell, but generally enclosing it in quotes should work.</para>
<para>If the <literal>-c</literal> (or <literal>--config</literal>)
command line option is given, its argument is treated as the name of a
directory to use to store configuration files and saved worlds. If it
is not given, the default is <filename>~/.kildclient</filename> under
Linux or <filename>kildclient</filename> under the Application Data
folder under Windows.</para>
<para>Alternatively, you may start KildClient from a menu in your
Windowing Environment. The exact way to launch KildClient will then
vary, but it should be just a matter of finding the menu entry and
clicking on it, or perhaps just cliking in an icon somewhere.</para>
</chapter>
<chapter><title>Basic Usage</title>
<para>This chapter will describe the most basic and important things you
need to know in order to use KildClient. It is recommended that you
read this section throughly, as it will ease understanding of the next
chapters.</para>
<sect1 id="sec:world-selector"><title>Connecting to a MUD</title>
<para>When you launch KildClient (see <xref linkend="chap:running"/>),
you'll see a screen like this one below:</para>
<figure><title>When KildClient is first started, you are asked to
connect to a world</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/firstscreen.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The screen shown when KildClient is first started.</phrase>
</textobject>
</mediaobject>
</figure>
<para>Before anything else, be aware that World is just a synonym for
MUD, and these two words will be used interchangeably in this
document.</para>
<para>The list of saved worlds may be empty, especially if this is the
first time ever KildClient is run.</para>
<para>You have two options: connect to a previously saved World, or
connect to a new one. To connect to a new one, you can either connect
direcly by typing the MUD's address and port in the boxes, or by
creating a new World.</para>
<para>Creating a new World is recommended because it allows you to
save options for that world, such as the font size or the colors used.
When you define triggers, aliases these will also be saved.</para>
<para>However, even if you connect directly, you can still customize
the World, and you have the option of saving it, so the difference
between the options is not so great.</para>
<para>To create a new World, press the button labeled
<guibutton>New</guibutton>. You'll be taken to the <emphasis>World
Editor</emphasis>, a dialog in which you can configure everything
about the World. We'll talk about the World Editor in <xref
linkend="chap:world_editor"/>. For now, fill in the
<guilabel>Name</guilabel>, <guilabel>Host</guilabel> and
<guilabel>Port</guilabel> fields, and click
<guibutton>OK</guibutton>.</para>
<para>To connect to a saved World, just select it and click the button
labeled <guibutton>Connect</guibutton>. Alternatively, you can
double-click the World in the list.</para>
<para>Sometimes you may see a little expander sign to the left of a
World's name, and when you click it some options appear inside that
World. This happens when there is more than one character associated
with that World (see <xref linkend="sec:we_general"/> for information
on auto-login and associating characters with a World). The list shown
is the list of all characters defined for that World. Select the entry
corresponding to the character you want to use to auto-login with that
character. If you select the main entry, the first character will be
used.</para>
<para>To connect directly, fill in the <guilabel>Host</guilabel> and
<guilabel>Port</guilabel> fields and click
<guibutton>Connect</guibutton>.</para>
<para>You can be connected to several Worlds simultaneously. To do
that, select the option
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Open</guimenuitem>
</menuchoice> from the menu. The World Selector dialog will be opened,
and you can select another World.</para>
</sect1>
<sect1 id="sec:interacting"><title>Interacting with the MUD</title>
<para>The figure below shows a typical KildClient session:</para>
<figure><title>A typical KildClient session with two open Worlds</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/typical.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>A typical KildClient session with two open Worlds.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The first thing to note is that, just like in other MUD clients,
there is an area where the output of the MUD is shown, and a text box
below where you can enter commands. You can edit the commands before
being sent, and only after you press <keysym>ENTER</keysym> the line
will be sent to the MUD.</para>
<para>The box that shows the output of the MUD keeps by default the
last 2000 lines received (but this number can be changed, see <xref
linkend="sec:we_misc"/>). You can recall the previous lines with the
scrollbar or with the <keysym>page up</keysym> and <keysym>page
down</keysym> keys.</para>
<para>A feature not so universal is the support for opening several
Worlds simultaneously, and using tabs to alternate between them. You
just need to click the tab to change to that World. If the name is
displayed in red, that means that there is new text in that MUD, text
you haven't seen yet. If the KildClient windows does not have focus
(that is, when you using another window and leave KildClient in the
background) and new text arrives in any World, the title of the
KildClient window will change to "(*) KildClient" to alert you of
that.</para>
<para>There are other ways to move to another open World. The keyboard
shortcuts <keysym>CTRL+Page up</keysym> and <keysym>CTRL+Page
down</keysym> move to the next or previous World, respectively.
Alternatively, you can use <keysym>ALT+Right arrow</keysym> o
<keysym>ALT+Left arrow</keysym> instead to achieve the same effect. To
got directly to a World, press <keysym>ALT+num</keysym>, where
<keysym>num</keysym> is a number from 1 to 9. This way you can move to
any one of the first nine open Worlds.</para>
<para>On the left of the command entry box there is a button with a
broom. Click on it to erase the whole command line.</para>
<para>You can recall recently typed commands with the arrow keys.
Pressing the <keysym>up arrow</keysym> recalls the previous command,
and the <keysym>down arrow</keysym> moves to the following
command. If the input box has multiple lines, as described below, then
use <keysym>Alt</keysym> and the arrows.</para>
<para>On the right, there is a button with an arrow poiting downwards.
Click on it to get a list of the last typed commands. Selecting one of
these commands will put it in the text box for you to repeat it,
possibly changing it before.</para>
<para>On the extreme right, there are two small arrows. These arrows
allow you to enlarge the input box if you type long input lines. The
input box can have from one to ten lines. The arrow pointing up
increases the size, the arrow pointing down decreases it.</para>
<para>The behaviour of input boxes with one or several lines is
different: if there is only one line, and more text than fits the
width is entered, the text is scrolled horizontally. On multi-line
input boxes, however, text that does not fit one line is wrapped to
the next line. A scroll-bar may be displayed if the whole text does
not fit in the number of lines selected.</para>
<para>As mentioned briefly before, the behaviour of the up and down
arrows is different. If the <keysym>Alt</keysym> key is held, then you
will retrieve other commands in the history. If you press just the up
and down arrows, it may retrieve another command or simply move the
cursor: if you have just sent a command or just retrieved a command,
then the arrow keys will move through other commands, but if you have
moved the cursor in order to edit, the up and down arrows will move to
the previous or next line. This may sound complicated, but is actually
natural, the arrows do what you expect them to do.</para>
<para>In the single-line input box (but not in the multi-line one), a
feature called <emphasis>command auto-completion</emphasis> is
enabled: when you start typing a command, a list of the previously
typed commands that start with the same string you've typed. You can
select one of them from the list to repeat it or change it.</para>
<para>However, in both input methods, you can type the start of a
command and press <keysym>Alt+Shift+Up arrow</keysym> to retrieve a
previous command that starts with the typed text. You can then use
<keysym>Alt+Shift+Up arrow</keysym> and <keysym>Alt+Shift+Down
arrow</keysym> to navigate through all the saved commands with that
prefix.</para>
<para>You can enter several commands at once in the command line
separating them with <literal>%;</literal>. For example, if you type
<literal>unlock door %; open door</literal>, two commands will be sent
to the MUD in sequence: first <literal>unlock door</literal>, and then
<literal>open door</literal>. Spaces around the <literal>%;</literal>
are ignore and can be used for clarity. Note: it is possible to
configure the command separator to be another string instead of
<literal>%;</literal>. See <xref linkend="sec:we_input"/>.</para>
<para>Another special feature of the command line is that you can
execute Perl statements from it. Starting a line with a slash
(<literal>/</literal>) causes that line not to be sent to the world,
but to be intepreted by the built-in Perl interpreter. To try it, type
in the command box <userinput>/$world->echonl("Hello, Perl
World!")</userinput>. You should see "<computeroutput>Hello, Perl
World!</computeroutput>" printed in the screen. What has happened is
that the command <userinput>$world->echonl("Hello, Perl
World!")</userinput> has been run by Perl, and this command causes a
string to be printed in the screen (but not to be sent to the MUD).
Don't worry if you do not understand the syntax yet, we will explain
it in <xref linkend="chap:perl"/>. For now, just keep in mind that if
you type a line starting with <literal>/</literal>, it will not be
sent to the MUD, but what follows the slash is treated as a Perl
command and executed.</para>
<para>Should you need to send a line that starts with
<literal>/</literal> to the MUD, use two slashes: entering
<userinput>//list</userinput> will send <userinput>/list</userinput>
to the MUD.</para>
<para>If you are using the multi-line input bar, you can enable to
built in spell checker to verify the text as you type. Misspelled
words will be highlighted with a red line below them, and you can
right-click on them to show a menu with possible spellings. To
configure this feature, see <xref linkend="sec:we_input"/>.</para>
</sect1>
<sect1 id="sec:closing_worlds">
<title>Closing Worlds and Exiting KildClient</title>
<para>When you are disconnected from a World (either because you
requested it, with the <literal>quit</literal> command or something
similar, or because the server has gone down), you will see a dialog
box from which you can choose from four options:
<guibutton>Reconnect</guibutton> will attempt to reconnect to the same
World (using the same character for auto-login, if there is more than
one defined, see <xref linkend="sec:we_general"/>). <guibutton>Connect
to another world</guibutton> will open the World Selection dialog (see
<xref linkend="sec:world-selector"/>) for you to choose another World
to connect to. <guilabel>Offline</guilabel> will keep the world open
so that you still see its output or execute some things with Perl.
Finally, <guibutton>Close</guibutton> will close the tab for that
World. If that was the only open World, KildClient will exit when you
press <guibutton>Close</guibutton>.</para>
<para>You can force disconnection from a World with the
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Disconnect</guimenuitem>
</menuchoice>
menu. Note that this is not the recommended way to leave a MUD, but it
might be necessary in other cases. The same dialog with the three
options will be shown.</para>
<para>If you choose
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Close</guimenuitem>
</menuchoice>
from the menu, the current World will be forcedly disconnected and
automatically closed (just as if you had selected
<guibutton>Close</guibutton> from the dialog). If this is the only
open World, KildClient will be exited.</para>
<para>To close all open Worlds and exit KildClient immediately, select
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Quit</guimenuitem>
</menuchoice>
from the menu.</para>
<para>These operations can also be run with Perl. To disconnect from a
World, use the <function>$world->dc</function> (that is, type
<userinput>/$world->dc</userinput> in the command box). To close the
World, use <function>$world->close</function>. And to quit KildClient
closing all Worlds, use <function>quit</function> (type
<userinput>/quit</userinput>, as you might imagine). The reason
<function>quit</function> does not have <literal>$world-></literal> in
front will be explained in <xref linkend="sec:perl_basics"/>, but for
now suffices to say that since it operates on all Worlds (and not in
one specific one), it does not have that.</para>
</sect1>
<sect1 id="sec:searching"><title>Searching Text</title>
<para>You can search the text saved in the buffer for occurrences of a
given word. To do that, use the
<menuchoice>
<guimenu>Edit</guimenu>
<guimenuitem>Find</guimenuitem>
</menuchoice>
menu.</para>
<para>When you select that menu, a bar appears above the command entry
box. Search is done through that bar. To start searching, type the
text you want to find in the entry box in the search bar. Searching in
KildClient is done <emphasis>incrementally</emphasis>, that is, as
soon as you type the first character, search starts (displaying the
first occurrence of that character). As you continue typing, searching
continues, always looking for occurrences of the text that you have
typed. If you are looking for a word, often you don't even need to
type the whole word, only the beginning is enough.</para>
<para>If you've found an occurrence of the text, but it is not the one
you intended, use the <guilabel>Find Next</guilabel> button beside the
entry box to find the next occurrence. (You can also use the
<menuchoice>
<guimenu>Edit</guimenu>
<guimenuitem>Find Next</guimenuitem>
</menuchoice>
menu.) Pressing the <keysym>Enter</keysym> key when in the input box
also activates the Find Next feature.</para>
<para>If the text you typed is not found, or if there are no more
occurrences of it when you press <guilabel>Find Next</guilabel>,
<guilabel>Not Found</guilabel> will be displayed in the search bar. In
this case, you can erase some characters and try again (if you made a
mistake), or reset the search and start again, as described
below.</para>
<para>To reset a search so that you can start again, either erase all
the text in the search box, or select
<menuchoice>
<guimenu>Edit</guimenu>
<guimenuitem>Find</guimenuitem>
</menuchoice>
from the menu again (which will also clear the entry box). When you do
that, searching will start again at the top of the buffer.</para>
<para>After you're done searching, click the small button with an
<guilabel>X</guilabel> in the left of the search bar to close the
search bar. You can also press <keysym>Esc</keysym> in the input
box.</para>
</sect1>
</chapter>
<chapter id="chap:world_editor"><title>Editing a World</title>
<para>This chapter will describe all the options found in the World
Editor that let you customize the behaviour of KildClient. Only
general options will be described here, some sections of the World
Editor, that allow you to configure features dealing with automation
(such as triggers, aliases, hooks, etc.) will be described in other
chapters, along with an explanation of that feature.</para>
<para>To access the World Editor for the currently open World, use the
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Edit</guimenuitem>
</menuchoice>
menu. It is also possible to edit Worlds from the World Selector
dialog, just click once in the World from the list and press
<guibutton>Edit</guibutton>.</para>
<para>There are several groups of options in that dialog. The
following sections will describe each one in turn.</para>
<sect1 id="sec:we_general"><title>General</title>
<para>The figure below shows the General section of the World
Editor:</para>
<figure><title>The General section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_general.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The General section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The first section, <guilabel>Connection</guilabel>, contains
parameters that specify how to connect to the MUD:</para>
<itemizedlist>
<listitem><para><guilabel>Name</guilabel>: this specifies the name
that will be shown in the World Selector, and also in the tab in the
main window. It can be anything you want, that helps you identify
the MUD.</para></listitem>
<listitem><para><guilabel>Host</guilabel>: the host to connect to.
It can be entered either as a name or as a numeric
IP.</para></listitem>
<listitem><para><guilabel>Port</guilabel>: the port to connect
to.</para></listitem>
<listitem><para><guilabel>Use SSL</guilabel>: if this is checked,
the communication with the MUD will be encrypted and thus immune to
casual eavesdropping. However, the MUD server must support this, if
you try to connect using SSL to a server that does not understand
it, the connection will fail.</para>
<para>Note: you might not see this option. If it is not present,
that means that you version of KildClient has been compiled
without SSL support.</para>
<para>Note: although the connection will be encrypted if the
connection uses SSL, KildClient does not attempt any kind of
certificate verification, so you must not assume that the
connection is authenticated. You can, however, see some
information on the certificate in the Statistics dialog (see
<xref linkend="mnu:statistics"/>).</para>
</listitem>
</itemizedlist>
<para>The second section, <guilabel>Auto-login</guilabel>, contains
the parameters that you need to configure if you want KildClient to
login automatically to the MUD for you. You can associate several
characters with a World, and then when you can select which character
you use to login to the MUD, as explained in <xref
linkend="sec:world-selector"/>.</para>
<para>First, select how the login will be made in <guilabel>Connection
Style</guilabel>. If this is set to "<guilabel>No
auto-login</guilabel>", no attempt will be made to login
automatically. This is the default.</para>
<para>There are two other options: "<guilabel>Diku</guilabel>", for
Diku-based mud servers, which prompt you for the character name and
then the password; and "<guilabel>lp</guilabel>" for lp-based mud
servers, in which you have to type <userinput>connect</userinput>
followed by the character name and password.</para>
<para>If neither of these options apply to your MUD, you should
disable auto-login here, but you can still use a hook to send commands
just after you connect. See <xref linkend="chap:hooks"/>.</para>
<para>Next follows a list of all the characters that you have defined.
Each character is associated with a password, however the password is
not displayed for security reasons.</para>
<para>To add a new character, press <guilabel>Add</guilabel> and enter
the character's name and password in the window that appears, then
press <guilabel>OK</guilabel>. The new character will be added to the
list. To edit an existing character, select it and press the
<guilabel>Edit</guilabel> button. To remove a character information,
select it and press <guilabel>Delete</guilabel>. Finally, to control
the order that the characters are displayed, use the
<guilabel>Up</guilabel> and <guilabel>Down</guilabel> buttons. Note
that the first character is considered the default and is the one used
if you connect using the main entry for that World.</para>
</sect1>
<sect1><title>Display settings</title>
<para>The Display category controls several aspects of the appearance
of KildClient. It is divided in sub-categories, which will be
described in the following sections.</para>
<sect2 id="sec:we_mainwindow"><title>Main Window</title>
<para>The figure below shows the Main Window section of the World
Editor:</para>
<figure><title>The Main Window section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_mainwindow.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Main Window section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>This section allows you to configure the main window where the
MUD text is shown.</para>
<para>You can set the font that is used for the text that is sent by
the MUD. Click on the button with the name of the font to pop-up a
dialog from where you can select another font. The change in the font
is applied immediately when a new font is selected.</para>
<para>Still with regard to fonds, another option that can be
configured in this section is whether to use bold fonts or not to
represent text that has the "bold" or "highlight" attribute set. By
default, this text is rendered in a lighter color and with a boldface,
but you can disable the use of a bold font from this dialog. You can
also change the colors used for the highlighted text, see <xref
linkend="sec:we_colors"/>.</para>
<para>You can also configure whether to use word wrap or not. If this
option is not set, lines will be broken when they do not fit the
window, even in the middle of a word. When this option is set, lines
will be wrapped between words, so that a word is not broken.</para>
</sect2>
<sect2 id="sec:we_colors"><title>Colors</title>
<para>The figure below shows the Colors section of the World
Editor:</para>
<figure><title>The Colors section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_colors.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Colors section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In this section you can configure the colors that will be used
by KildClient. The ANSI standard defines eight colors, both in the
"normal" state and in the "bold" state. These "bold" colors are by
default shown with lighter colors, and, optionally, with a bold font
also (see <xref linkend="sec:we_mainwindow"/>). Additionally, there are
"default" colors for the foreground and background, when no specific
color is set.</para>
<para>You can tweak the colors so that they look better in your
screen, or redefine them completely. To do that, click in the button
with the color, and a dialog will be shown for you to change the
color. The changes are applied immediately when a new color is
chosen.</para>
<para>Should you want to revert all colors to their built-in preset
values, use the <guibutton>Revert to default colors</guibutton>
button.</para>
</sect2>
<sect2 id="sec:we_statusbar"><title>Status Bar</title>
<para>The figure below shows the Status Bar section of the World
Editor:</para>
<figure><title>The Status Bar section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_statusbar.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Status Bar section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The first section allows you to change the font used in the
status bar. Click the button and a dialog will appear for you to
select the font.</para>
<para>The second section controls the display of some time counter
that appear in the right of the status bar. You can display the
total time connected to this world and/or the idle time, that is, the
time elapsed since you last sent a command to the MUD.</para>
<para>For each time, there are three options. <guilabel>Do not
display</guilabel> causes that time not to be displayed.
<guilabel>Display as hours, minutes and seconds</guilabel> displays
the time as something like 2h45m30s, while <guilabel>Display as
seconds</guilabel> would display that previous time as 9930s.</para>
<para>The behavior of the idle time counter can also be configured
with the <guilabel>Only reset idle time counter when a command is
entered</guilabel> checkbox. When the checkbox is unchecked (which is
the default), that time is reset whenever a command is sent to the
world, no matter if this command was typed, if it ran because of a
trigger, a timer, etc. When checked, the timer will only be reset when
you enter something in the command entry box and press
<keysym>ENTER</keysym>. Automatically sent commands will not cause the
counter to be reset.</para>
</sect2>
</sect1>
<sect1 id="sec:we_input"><title>Input</title>
<para>The figure below shows the Input section of the World
Editor:</para>
<figure><title>The Input section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_input.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Input section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The first section, <guilabel>Command Entry</guilabel>, controls
the behaviour of the command entry textbox:</para>
<itemizedlist>
<listitem><para><guilabel>Keep last typed command in command entry
box</guilabel>, causes the entry box not to be cleared when you
press <keysym>ENTER</keysym>. The command you have just sent will be
kept and can be repeated just by pressing <keysym>ENTER</keysym>
again. It will be selected, so you can start typing another command
to erase it.</para></listitem>
<listitem><para><guilabel>Echo sent commands in terminal
window</guilabel> controls whether the commands that are sent to the
MUD are also echoed to the MUD window.</para></listitem>
<listitem><para><guilabel>Number of commands to save in
history</guilabel> specifies the number of commands that are saved
and can be recalled with the arrow keys, with the button to the
right of the entry box, or with command completion. If this is set
to too high a number, KildClient will consume more
memory.</para></listitem>
<listitem><para><guilabel>Command separator</guilabel> allows you to
configure the token used to separate commands. By default it is
<literal>%;</literal>.</para></listitem>
<listitem><para><guilabel>Use single-line input bar</guilabel> and
<guilabel>Use multi-line input bar</guilabel> define the size of the
input bar. If set to single-line, it will have only one line, and if
you type more text than fits the width, the text will scroll
horizontally. If, however, you select a multi-line input bar, the
bar will have two or more lines, and text will wrap and be displayed
in the next line. (Scroll-bars may be displayed if there is more
text than fits.)</para>
<para>If set to multi-line, you can specify how many lines to
reserve for the input bar, from two to ten.</para></listitem>
<listitem><para><guilabel>Enable auto-completion</guilabel> controls
whether the auto-completion feature (see <xref
linkend="sec:interacting"/>) is enabled or not. However,
auto-completion only works for single line input
bars.</para></listitem>
<listitem><para>When auto-completion is enabled, you can specify
after how many characters have been typed it will be activated. Just
enter the number in the text box <guilabel>Activate auto-completion
only after X characters have been
entered</guilabel>.</para></listitem>
<listitem><para><guilabel>Spell check typed text</guilabel>, if
checked, enables the built-in spell checker. This spell checker
works only with the multi-line input bar. If it is active,
misspelled words are highlighted with a red line below them.
Right-clicking on them pops up a menu with spelling
suggestions.</para>
<para>By default, the language used for spell checking is based on
your current locale. If you want to set a specific language, enter
its language code (as recognized by the aspell backend) in the
box.</para>
<para>Note that for spelling to work you need the gtkspell library.
Your version might have been compiled without spelling
support.</para></listitem>
</itemizedlist>
<para>The <guilabel>Font</guilabel> section allows you to configure
the font that is used in the command entry box. Click the button and a
dialog will appear for you to select the font.</para>
<para>The <guilabel>Flood Prevention</guilabel> feature is also
configured in this section. This feature is useful in MUDs that
disconnect you if you type 20 equal commands in a row, or something
like that. When you enable this feature, KildClient will count the
number of repeated commands you send. When you try to send the same
command for the 20th time, KildClient will send another command you
specify before, thus breaking the chain of repeated commands.</para>
<para>To use this feature, make enable the check box <guilabel>Do not
allow the same command to be sent X times in a row</guilabel>. Change
X for the number of equal commands that will disconnect you.</para>
<para>The <guilabel>Send this command</guilabel> textbox specifies
the command that will be sent to prevent too many equal commands to be
seen by the MUD. It should be set to a harmless command, because it
might be sent anytime.</para>
</sect1>
<sect1 id="sec:we_automation"><title>Automation</title>
<para>This section allows you to configure the features that make your
MUD playing experience easier, faster and more efficient. You can
define triggers, aliases, hooks, etc. here. These sections of the
World Editor will be described elsewhere, along with a description of
the features. Here we will deal with another section that is more
generic.</para>
<sect2 id="sec:we_scripting"><title>Scripting</title>
<para>The figure below shows the Scripting section of the World
Editor:</para>
<figure><title>The Scripting section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_scripting.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Scripting section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>There is only one parameter to be configured in this section:
<guilabel>Perl file to load</guilabel>. It allows you to specify a
file that will be read by the Perl interpreter when the World is
loaded. This file can contain sub-routine definitions that will be
available for you to use in your triggers, aliases etc., or to be
called directly. For more details, see <xref
linkend="sec:perl_basics"/>.</para>
<para>Enter the path to the file in the textbox, or click the button
next to it to open a dialog from which you can select a file.</para>
</sect2>
</sect1>
<sect1 id="sec:we_protocols"><title>Protocols</title>
<para>The figure below shows the Protocols section of the World
Editor:</para>
<figure><title>The Protocols section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_protocols.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Protocols section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>Here you can configure how KildClient uses some protocols to
enhance the player's experience while playing the MUD. Currenly you
can configure how KildClient behaves with regard to the MCCP protocol,
which compresses data sent by the MUD so that less data needs to be
sent.</para>
<para>By default, KildClient will use this protocol if the server
proposes it, but only if this proposal comes in at most one minute
after the connection has been established. This is done in order to
prevent bad players from trying to crash your client by sending the
special sequence that enables compression. Note, however, that
well-written servers prevent the user from sending such sequences to
other users. However, as compression is generally negotiated just
after connecting, leaving this option in its default state,
<guilabel>Enable if server proposes after connecting</guilabel> is
recommended.</para>
<para>If <guilabel>Enable if server proposes at any time</guilabel> is
selected, MCCP will be started whenever the start sequence is
received, no matter at what time.</para>
<para>Finally, you can disable MCCP altogether by selecting
<guilabel>Disable</guilabel>. This way sequences asking for
compression will be ignored, and the server will never send compressed
data. Attempts by malicious players will not succeed.</para>
</sect1>
<sect1 id="sec:we_misc"><title>Miscellaneous</title>
<para>The figure below shows the Miscellaneous section of the World
Editor:</para>
<figure><title>The Miscellaneous section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_misc.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Miscellaneous section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>There is only one category, <guilabel>Scrolling</guilabel>,
which controls the behavious of the scrollback buffer.</para>
<itemizedlist>
<listitem><para><guilabel>Scroll on output</guilabel>, when checked,
will cause the buffer to always scroll the end when new text is
received, thus displaying it immediately. If not checked, the buffer
is only scrolled if you are at the end.</para></listitem>
<listitem><para><guilabel>Lines to save in scrollback
buffer</guilabel> determines how many lines of output will be saved
in the buffer for you to see again. Note that KildClient will get
slower and will consume more memory if you set this to too high a
number.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="sec:we_advanced"><title>Advanced</title>
<para>The figure below shows the Advanced section of the World
Editor:</para>
<figure><title>The Advanced section of the World Editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_advanced.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Advanced section of the World Editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In most cases, you will not need to change any of the settings
of this section.</para>
<para>The <guilabel>File</guilabel> text box specifies the file where
the World is saved. It is not necessary to enter anything here, a file
name will be generated automatically if you leave it blank. If you
enter a file name, it will override the default name. This means that
you can create a copy of a World by editing it, giving a new file
name, and then saving.</para>
<para>Note, however, that for the World to be recognized and listed in
the World Selector, it must have the <filename
class="extension">.wrl</filename> extension, and must be in the
directory where KildClient stores its files (<filename
class="directory">~/.kildclient</filename> under Linux and other
UNIX-like systems).</para>
<para>Another thing that can be configured in this section is the
character set used by KildClient. If you do not know what is that,
then simply ignore it and do not change anything. If you do know, just
select the character set that is used by the MUD from the combo box.
However, keep in mind that internally KildClient works with the UTF-8
character set. The only things that are changed by the selection you
can make in this section are what is output by the MUD and what is
sent to the MUD.</para>
<para>Finally, you can configure some aspects of the editors for
triggers, aliases, macros, timers and hooks (all displayed in the
World Editor).</para>
<para>You disable the confirmation dialogs that appear when you try to
delete a trigger, alias, macro, etc. from one of the graphical
editors. If you disable the <guilabel>Ask for confirmation before
deleting triggers, aliases, etc.</guilabel> there will not be a
confirmation dialog and the item will be deleted immediately. Be
warned that if this is unchecked and some item is deleted, you will
need to create it again if you delete it by mistake.</para>
<para>You can also show triggers and other objects defined by plugins
that are currently loaded. By default they are not shown, but you can
change this cheking the <guilabel>Show items defined by
plugins</guilabel> checkbox.</para>
<para>Note, however, that while having that option checked will allow
you to edit, delete and reorder the items defined by plugins, these
changes <emphasis>will not</emphasis> be made in the plugin file, and
the next time the plugin is loaded, the items will be as they were
before. You can use the editors to make changes and tests, but you
will need to alter the plugin file afterwards.</para>
</sect1>
</chapter>
<chapter id="chap:preferences"><title>Configuring KildClient</title>
<para>The previous Chapter described how to configure a World. Those
settings are individual for each World. There are some settings,
however, that apply to KildClient as a whole, which will be described
in this Chapter.</para>
<para>To access those settings, use the
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Preferences</guimenuitem>
</menuchoice>
menu. The following sections will describe the groups in the
Preferences dialog.</para>
<sect1><title>Appearance</title>
<para>The figure below shows the Appearance section of the Preferences
dialog:</para>
<figure><title>The Appearance section of the Preferences dialog</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/pref_appearance.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Appearance section of the Preferences dialog.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In this section you configure the colors that KildClient uses
for its own purposes. (The configuration of the colors that the MUD
displays is explained in <xref linkend="sec:we_colors"/>.)</para>
<para>Two colors can be configured: <guilabel>Informative
messages</guilabel> is the color used by KildClient to print messages
about the status of the connection, such as the ones showing that a
connection is being tried or has succeeded. <guilabel>Command
echo</guilabel> specifies the color in which the commands you send to
the World are printed in the screen (if this feature is enabled, see
<xref linkend="sec:we_misc"/>).</para>
<para>In each case, select from the drop-down list the color you want.
Note that the actual color that is displayed depends on how it was
configured in the World Editor (see <xref
linkend="sec:we_colors"/>).</para>
<para>Another thing to be configured here is the position where the
tabs representing the open Worlds are displayed. They can be at the
top, bottom, left or right. Select the one you want from the combo
box.</para>
<para>Finally, you can enable or disable the <guilabel>Flash window
when new text is received</guilabel> feature. When it is enabled, if
text is received in the mud while you are at another window,
KildClient's window will flash to draw your attention. If disabled,
you can still know that new text has been received because the
titlebar will have a <literal>(*)</literal> prepended. Note, however,
that the exact behaviour of this feature might depend on your Window
Manager, and that some window managers do not do anything for windows
with the "Urgent" flag set.</para>
</sect1>
<sect1><title>Sending</title>
<para>The figure below shows the Sending section of the Preferences
dialog:</para>
<figure><title>The Sending section of the Preferences dialog</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/pref_sending.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Sending section of the Preferences dialog.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In this section you configure the default paramenters used when
sending several commands at once. This setting is used in the Command
History (<xref linkend="sec:cmd_history"/>) and Multi-line Send
(<xref linkend="sec:ml_send"/>) dialogs.</para>
<para>You specify the number of commands or lines that are sent
simultaneously, and the delay between sending each group of
commands/lines (containing the specified number of commands/lines,
naturally). Note, however, that the values you set here are only
defaults, you can change the values in the dialogs of those features
if you need so.</para>
</sect1>
<sect1 id="pref:progs"><title>External Programs (Linux)</title>
<para>This section of the Preferences dialog only appears when
KildClient is run in Linux.</para>
<para>The figure below shows the External Programs section of the
Preferences dialog:</para>
<figure><title>The External Programs section of the Preferences
dialog</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/pref_progs.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The External Programs section of the Preferences
dialog.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In this section you can configure the command that will be run
when you right-click in a URL that appears in the MUD window and
select <guilabel>Open Link</guilabel>. The command will be executed,
with <literal>%s</literal> replaced with the URL's address. The
ampersand (<literal>&</literal>) in the end means that the command
is to be executed in the background, so that you can continue using
KildClient while browsing the URL.</para>
<para>You can also set a command used to play audio files (see <xref
linkend="sec:sounds"/>). Enter the command, with <literal>%s</literal>
in the place of the file path. The default should work (it uses the
SOX program, which is usually installed), but you can use other
commands if you use ALSA, ARTS, ESD, JACK, etc.</para>
</sect1>
</chapter>
<chapter><title>Menu Reference</title>
<para>This chapter will describe all the menus and their commands in
KildClient.</para>
<sect1><title>World menu</title>
<sect2><title>Open</title>
<para>This menu command opens the World Selector dialog for you to
connect to a World, either a saved one or a new one. You can also edit
the saved worlds from the World Selector dialog.</para>
<para>See <xref linkend="sec:world-selector"/> for more information
on opening Worlds.</para>
</sect2>
<sect2><title>Reconnect</title>
<para>If you are not connected to a World, but have it still open (in
offline mode), use this menu to connect again to the World. If you are
connected, this command closes the current connection and reopens
it.</para>
</sect2>
<sect2><title>Disconnect</title>
<para>This command closes the connection to the World. Note that this
is not the recommended way to exit from a MUD, you should use the
proper command (generally <userinput>quit</userinput>).</para>
</sect2>
<sect2><title>Connect to Another</title>
<para>This command opens the World Selector (see <xref
linkend="sec:world-selector"/>) for you to connect to another World
using the same tab. If you are still connected to a World, the
connection will be closed.</para>
</sect2>
<sect2><title>Close</title>
<para>This command closes the connection to the World (if it is open)
and closes the current tab. If this is the only tab, the program is
exited.</para>
</sect2>
<sect2><title>Edit</title>
<para>This command brings up the World Editor for you to configure the
World. See <xref linkend="chap:world_editor"/>.</para>
</sect2>
<sect2><title>Save</title>
<para>This command saves any changes made to the World to the disk so
that they are made permanent. Note that whenever a World is closed, it
is automatically saved before.</para>
</sect2>
<sect2 id="mnu:statistics"><title>Statistics</title>
<para>This command opens a dialog showing some information and
statistics about the currently open World. If the version you are
running supports SSL and you are connected using SSL (see <xref
linkend="sec:we_general"/>), some information about the SSL session
and the certificate are displayed.</para>
</sect2>
<sect2><title>Previous and Next</title>
<para>These two commands allow you to navigate between the open
Worlds, going to the next or previous tabs, repectively.</para>
</sect2>
<sect2><title>Quit</title>
<para>This command exits KildClient, closing any open Worlds. If an
open world has "OnCloseConnected" hooks (see <xref
linkend="chap:hooks"/>), they are executed. If there is at least one
open world without such hook, you are asked for confirmation
first.</para>
</sect2>
</sect1>
<sect1><title>Edit Menu</title>
<sect2><title>Cut</title>
<para>This command copies the text selected in the command entry box
to the clipboard and deletes the selected text.</para>
</sect2>
<sect2><title>Copy</title>
<para>This command copies text either from the MUD (that is, in the
output window) or from the command entry box to the clipboard.</para>
<para>If there is text selected in the main window, than this text is
copied. Otherwise, if there is text selected in the command entry box,
it is this text that is copied.</para>
</sect2>
<sect2><title>Paste</title>
<para>This command pastes the text in the clipboard to the command
entry box, possibly overwriting any selected text.</para>
</sect2>
<sect2><title>Delete</title>
<para>This command deletes the text selected in the command entry
box.</para>
</sect2>
<sect2><title>Find and Find Next</title>
<para>These commands are used to search for some text in the output
buffer. Their use is described in <xref linkend="sec:searching"/>.</para>
</sect2>
</sect1>
<sect1><title>Input Menu</title>
<sect2><title>Clear</title>
<para>This command clears the command entry box. The same can be
achieved by using the button to the left of the command entry
box.</para>
</sect2>
<sect2><title>Previous and Next</title>
<para>These commands retrieve the previous or next command in the
history, putting them in the command input box. They are equivalent of
pressing <keysym>Alt+Up</keysym> or <keysym>Alt+Down</keysym> (or just
the arrows, in some circunstances).</para>
</sect2>
<sect2><title>Find Previous and Find Next</title>
<para>These commands search the command history for a command that
starts with the text that is in the input bar. To use that feature,
enter the first characters of the command you want to retrieve and
select Find Previous. You can navigate through other commands starting
with that prefix with these menu entries.</para>
</sect2>
<sect2 id="sec:cmd_history"><title>Command History</title>
<para>This command allows you to review the commands that have been
sent recently, and send one or more commands again. When you select
the menu item, a dialog like this appears:</para>
<figure><title>Command History Dialog</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/cmdhistory.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Command History Dialog.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The list on the left shows the commands which are saved. You can
configure how many commands are saved, see <xref
linkend="sec:we_input"/>.</para>
<para>To send again commands to the World, select the commands you
would like to send and press <guilabel>Send</guilabel>. Since most
MUDs cannot handle too much user input at once and disconnect you in
this case, you can add a delay after each sent command, so that the
commands are not sent all at once, but with pauses. You can specify
the delay and also how many commands are sent at one time. The delay
is added after each group of sent commands.</para>
<para>You can also press <guilabel>Send & Close</guilabel> to send
the selected commands and close the dialog afterwards.</para>
<para>You can also put a command in the command entry box to edit it.
To do so, select a command (in this case you must select only one) and
press <guilabel>Recall</guilabel>. If you press <guilabel>Recall &
Close</guilabel> instead, the command is recalled and the dialog is
closed.</para>
<para>To search for commands containing a given string, used the
<guilabel>Find</guilabel> and <guilabel>Find Next</guilabel> buttons.
Use the former one to start a search, and the later to find more
commands with the string. To start another search, use
<guilabel>Find</guilabel> again.</para>
</sect2>
<sect2 id="sec:ml_send"><title>Multi-line Send</title>
<para>This command allows you to send several lines of output and/or a
file to the World. When you select the menu item, a dialog like this
appears:</para>
<figure><title>Multi-Line Send</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/mlsend.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Multi-Line Send Dialog.</phrase>
</textobject>
</mediaobject>
</figure>
<para>You can send a file to the World, and you can also send text
before and after the file if you need. Naturally, you can also send
only some text without sending a file. Just leave the fields you don't
need blank.</para>
<para>It is also possible to prefix all the lines with a string (such
as <literal>chat</literal>), or to add a string to the end of all
lines. If you want that, fill in the appropriate fields, if not, just
leave them blank.</para>
<para>Most MUDs cannot handle too much user input at once and
disconnect you in this case. To avoid that, you can add a delay after
each sent lines, so that the text is not sent all at once, but with
pauses. You can specify the delay and also how many lines are sent at
one time. The delay is added after each group of sent lines.</para>
<para>If you select "Keep dialog open after sending", the dialog will
not be closed after the text starts to be sent, so you can make
further changes to the text.</para>
</sect2>
<sect2><title>Test Triggers</title>
<para>This command brings up the Test Triggers window, which is
described in <xref linkend="sec:test_triggers"/>.
</para>
</sect2>
</sect1>
<sect1><title>Preferences Menu</title>
<sect2><title>Disable Triggers, Aliases, Macros or Timers</title>
<para>If each of these menu entries is checked, then the corresponding
automation feature is disabled: lines are not matched against
triggers, aliases do not replace typed commands, macros and timers do
not run. Use them if you want to temporarily disable all of them,
since the triggers, aliases, macros or timers are not deleted.</para>
</sect2>
<sect2><title>Debug Matches</title>
<para>If this entry is selected, whenever a trigger or alias matches,
information is printed about it. The information is printed on stdout,
which means you must start KildClient from a terminal.</para>
</sect2>
<sect2><title>Preferences</title>
<para>This command opens a dialog where you can configure some aspects
of KildClient global to all Worlds. See <xref
linkend="chap:preferences"/>.</para>
</sect2>
<sect2><title>Edit Default World</title>
<para>This command opens a dialog where you can set some default
parameters used for Worlds. For example, you can define your preferred
font or colors, and all new Worlds will use these default font and
colors.</para>
<para>The things that can be set are described in <xref
linkend="chap:world_editor"/>, but not all things described there can
be set as default parameters. (There's no sense in having a default
World name, for example.)</para>
</sect2>
</sect1>
<sect1><title>Help Menu</title>
<sect2><title>Help</title>
<para>This commands opens a browser showing the KildClient manual
(which you are reading now).</para>
</sect2>
<sect2><title>About</title>
<para>This commands shows a window with some information about the
program.</para>
</sect2>
</sect1>
</chapter>
<chapter id="chap:perl"><title>Using Perl in KildClient</title>
<para>This chapter will describe briefly how to use Perl (Practical
Extration and Report Language, or, according to some, Pathologically
Eclectic Rubbish Lister) in KildClient. Even though it will give a few
examples of things that would certainly be known already by people who
know Perl, this Chapter is not meant to be a Perl tutorial. If you
want to learn Perl from the start, you should read its man pages, find
a tutorial or a good book on the subject (there are plenty of these).
Some knowledge of Perl will certainly help in understanding this
Chapter.</para>
<sect1 id="sec:perl_basics"><title>The Basics</title>
<para>KildClient has a built-in Perl interpreter. To run a perl
statement, just type if preceded by a slash (<literal>/</literal>) in
the command entry box. The statement will be executed by the Perl
interpreter instead of being sent to the MUD.</para>
<para>The statement can be anything that Perl will accept. You can
actually execute several Perl statements if you separate them with
<literal>;</literal> (no need to add <literal>/</literal> again, just
once in the beginning of the line). You can call sub-routines, execute
conditional or loop constructions, call a built-in function, do
variable assignments, or even define a sub-routine. However, the
statement must be complete. You cannot enter something like
<userinput>/$myVar =</userinput> and then enter
<userinput>/"some_value";</userinput>, the statement must be complete
in one line. Technically, each line you enter is executed inside an
<function>eval</function> block, so anything you want executed must be
valid code inside an <function>eval</function> block.</para>
<para>All built-in Perl functions are accessible for you to use, and
you can load Perl modules and use their functionality. However, that
is not enough, because Perl's built-in functions will not allow you to
interact with the World. Because of that, KildClient defines a set of
functions that you can use to interact with the World. A full list
describing them detailedly is found in <xref
linkend="app:functions"/>, but some of the most useful ones will be
described in this Chapter. Many of these functions deal with creating
and editing triggers, gags, aliases etc. These will be described in
the corresponding chapters.</para>
<para>It is possible to get help on all functions using the
<function>help</function> function. It takes as argument the name of
the function. Note that since <function>help</function> is nothing
else than another Perl function, the name of the function for which
you want help is just an argument to it, and must be passed as a
string. That is, to get help on the <function>echo</function>
function, type <userinput>/help "echo"</userinput>. (Naturally, you
can enclose <parameter>"echo"</parameter> in parenthesis, but this is
not necessary.)</para>
<para>Some functions are in a way global, that is, they do not refer
to a specific world. One such example is <function>colorize</function>
(see <xref linkend="func:colorize" endterm="func:colorize.title"/>),
which inserts ANSI color codes in strings (useful when you want to
print something in the screen). These are called like any built-in
Perl function. For example, if you enter <userinput>/$colorstr =
colorize("&WI'm in white!")</userinput>, the variable
<varname>$colorstr</varname> will hold a string that would be printed
in white.</para>
<para>Many functions, however, are specific to a World, such as
<function>echo</function> (see <xref linkend="func:echo"
endterm="func:echo.title"/>), which prints something in the World
window (but does not send it to the World). Because of that, they are
called in a slightly different way. To print that string which has
just been created, you would enter
<userinput>/$world->echo($colorstr)</userinput>. Those that know
Perl will recognized this as a method call of the
<varname>$world</varname> instance. Indeed, <varname>$world</varname>
is an instance of the class <classname>World</classname> class. This
class defines several functions that allow interaction with a World.
On start-up, the <varname>$world</varname> variable is created and
references the current World.</para>
<para>It is also possible to control other worlds, if you have a
variable pointing at them. You can get such a variable with the
<function>getworld</function> function (see <xref
linkend="func:getworld" endterm="func:getworld.title"/>). In that
case, you should use the variable you got instead of
<varname>$world</varname>.</para>
<para>If all the above did not make sense to you, do not worry. Just
remember that many functions have to be called by adding
<literal>$world-></literal> to the front. These functions will always
be listed with that in front.</para>
<para>When a World is opened, the Perl interpreter reads and executes
a file you specify. (See <xref linkend="sec:we_scripting"/> for
information on how to specify the file.) In this file, you can define
sub-routines and variables. They will be then available for you to use
during your session. If you define a sub-routine called
<function>sendGreetings</function>, you can type
<userinput>/sendGreetings</userinput> and the sub-routine will be
executed. Or, if you define a variable, you can use it
anywhere.</para>
<para>It should be noted that each World has its own Perl interpreter,
with its functions and variables. What you do in one World does not
affect the others.</para>
</sect1>
<sect1><title>Echoing and Sending Text</title>
<para>As mentioned in the previous section, the
<function>$world->echo</function> function is used to print (or
<emphasis>echo</emphasis>) text to the MUD window, without sending it
to the World. It works like the <function>print</function> built-in
function: it accepts any number of arguments, and echoes all of them,
sequentially.</para>
<para>For example, <userinput>$world->echo("Variable var contains ",
$var, ".\n")</userinput> would print the first string, followed by the
contents of <varname>$var</varname>, followed by a period and a new
line. Of course, you could do all that in a single string using
variable interpolation.</para>
<para>A variant of <function>$world->echo</function> is
<function>$world->echonl</function>. The difference is that
<function>$world->echonl</function> always prints automatically a
newline after each argument. This is just a shorthand to make some
things simpler and possibly more readable.</para>
<para>Similar to <function>$world->echo</function> is the
<function>$world->send</function> function. This function sends
something to the MUD. For example,
<userinput>$world->send("who")</userinput> will have the same effect
as if you had typed <userinput>who</userinput> in the command entry
box and pressed <keysym>ENTER</keysym>. Note that you do not have to
add a newline to the end of the line to send, because
<function>send</function> automatically sends a newline after each
argument (since commands must be terminated by a newline for the MUD
to recognize them).</para>
<para>It is possible to pass several arguments to
<function>send</function>. If you do so, each argument will be sent as
a separate command. For example, <userinput>$world->send("who",
"look")</userinput> will first send a <literal>who</literal> to the
MUD, and then a <literal>look</literal>, just as if you had typed each
of these commands in order.</para>
<para>All the examples given above did nothing that could not be done
without Perl, and using <function>send</function> for that was
actually less efficient that typing the commands directly. However,
when combined with variables and/or control flow structures,
<function>send</function> can actually be quite useful.</para>
<sect2 id="sec:paths"><title>Paths and Speed-Walking</title>
<para>A useful feature of some MUD clients, which KildClient
implements, is the support for <emphasis>speed-walking</emphasis>.
This feature allows you to define paths to go directly from one place
to another without having to type a lot of movement commands.</para>
<para>For example, suppose that to go to some place from a fixed point
(such as the center of a town) you need to take the following
directions: <literal>s s s e e s e e e e n nw n</literal>. This is
often written in a more compact way as <literal>3s 2e s 4e n nw
n</literal>. KildClient allows you to send to the MUD all the 13
required commands in a single command. To do that, use the
<function>path</function> function. For example, if you enter
<userinput>/path("3s2es4en{nw}n")</userinput> in the command line, 13
commands will be sent to the MUD: exactly the 13 that form the path
defined above.</para>
<para>Note the syntax: the movement commands are defined one after
another, optionally prefixed by a number, which determines how many
times that command will be sent. So <literal>3s</literal> means send
<literal>s</literal> three times. If there is no number, the command
is sent only once.</para>
<para>Note also that the command to move to the north-west is enclosed
in braces: <literal>{nw}</literal>. This is because if the
<function>path</function> function sees <literal>nw</literal>, it will
think you want to move to the north than to the west. Enclosing it in
braces causes <function>path</function> to see that as a single
command. Should you need to move several times to the northwest, you
can add a number before: <literal>4{nw}</literal> will send
<literal>nw</literal> four times.</para>
<para>Naturally, you can include any command that is not a single
letter in braces to force <function>path</function> to see it as a
command. It is likely that some paths will need something like
<literal>{open door}</literal> in the middle.</para>
<para>Of course, simply entering paths in the command line is not that
useful. But you can store the path in a variable, and then just call
<userinput>path($stored_path)</userinput>. Just add a line that
defines the variable to you script file (see <xref
linkend="sec:perl_basics"/>), and you will be able to use the
variabled anywhere.</para>
<para>Alternatively, you can define an alias (see <xref
linkend="chap:aliases"/>) or a macro (see <xref
linkend="chap:macros"/>) to execute your path even faster. The
<literal>easypath</literal> plugin does that, see section <xref
linkend="plugin:easypath"/>.</para>
</sect2>
</sect1>
<sect1 id="sec:sounds"><title>Playing Sounds</title>
<para>To play a sound (for example, as the action of a trigger, to
call your attention), use the <function>play</function> function. Pass
it the path to the sound file, for example:
<userinput>/play("/home/joe/sounds/beep.wav")</userinput>.</para>
<para>Under Windows, this function supports playing WAV files. Under
Linux, you must set-up a command to play sounds, see <xref
linkend="pref:progs"/>.</para>
</sect1>
<sect1><title>Saving Variables Permanently</title>
<para>You can define variables for use in your Perl scripts. Since
KildClient has a full-featured Perl interpreter, you can use all kinds
of variables Perl supports (scalars, arrays, hashes, and even
references to build complex data structures), and you use them just
like you would in Perl.</para>
<para>However, when you close the World, the variables and their
values are lost. However, it is often desirable to keep the values of
variables across sessions, and KildClient has a mechanism for
that.</para>
<para>A variable can be made <emphasis>permanent</emphasis>. All
variables that are marked as permanent will be saved when you close
the World, and will be reloaded from the saved values when the World
is opened again later. This way, their values are saved across
sessions.</para>
<para>To make a variable permanent, open the World Editor (see <xref
linkend="chap:world_editor"/>) and select the
<guilabel>Variables</guilabel> section inside
<guilabel>Automation</guilabel>.</para>
<para>There you will see a list of the variables that are set to be
permanent:</para>
<figure><title>Permanent Variables</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_vars.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>Permanent Variables.</phrase>
</textobject>
</mediaobject>
</figure>
<para>To add a variable, click the <guilabel>Add</guilabel> button. A
window will open for you to enter the name of the variable.</para>
<para>To make one or more variables temporary again, select them and
press <guilabel>Delete</guilabel>. They will be removed from the
list.</para>
<para>Finally, if you mispell the name of a variable, select it and
press <guilabel>Edit</guilabel> to correct it.</para>
<para>You can also change the order of the variables with the
<guilabel>Up</guilabel> and <guilabel>Down</guilabel> buttons. This is
usefor for grouping similar variables together, but does not otherwise
affect the saving of the variables.</para>
<sect2><title>Permanent Variables in the Command Line</title>
<para>It is possible to make a variable permanent from the command
line. To do that, use the <function>$world->makepermanent</function>
function, passing the name of the variable as the argument. Note that
since you must pass the name of the variable, you must use quotes, and
preferably single quotes so that the variable does not get
interpolated. For example, to make the variable
<varname>$kill_count</varname> permanent, run
<userinput>$world->makepermanent('$kill_count')</userinput>. Now when
you close the World, the value of <varname>$kill_count</varname> will
be saved, and when you reopen it later, the value will be
restored.</para>
<para>It is possible to make more than one variable permanent at one
time, just pass all their names as arguments to
<function>$world->makepermanent</function>.</para>
<para>If you want a variable to stop being permanent (that is, to
become <emphasis>temporary</emphasis> again), use the
<function>$world->maketemporary</function> function. It is called just
like <function>makepermanent</function>, and has the opposite
effect.</para>
<para>To get a list of the variables that are currently permanent, use
the function <function>$world->listpermanent</function>. This function
has no arguments, and prints all the names of the variables that are
permanent.</para>
</sect2>
</sect1>
<sect1><title>Controlling Worlds with Perl</title>
<para>In <xref linkend="sec:closing_worlds"/> it was explained that
you can disconnect from a World with the
<function>$world->dc</function> function. It now should be clear why
there is a <literal>$world-></literal> in front. Another function that
you know already is <function>$world->close</function>, to disconnect
and close a World.</para>
<para>There are a few more functions that allow you to control Worlds
from Perl. The <function>$world->next</function> and
<function>$world->prev</function> move to the next or previous world
in the list of tabs. It is also possible to pass an argument to them,
specifying how many Worlds to move. So,
<userinput>$world->next(2)</userinput> moves two Worlds forward, and
<userinput>$world->prev(3)</userinput> moves three Worlds back.</para>
<para>To go to a specific World, use the <function>gotow</function>
function (which <emphasis>does not</emphasis> belong to the
<classname>World</classname> class, since it does not depend on a
particular World), passing as argument a string with the name of the
World.</para>
<para>Finally, you can use the <function>quit</function> function to
disconnect and close all Worlds and then exit KildClient.</para>
</sect1>
</chapter>
<chapter id="chap:triggers"><title>Triggers</title>
<para>Triggers allow you to react automatically to text that comes
from the MUD. This reaction can be of two forms: sending something to
the MUD in reply, or there may be no direct interaction with the MUD,
but something might be printed in the screen, or something else done
to call your attention.</para>
<para>Sometimes the action of a trigger is to change the line that was
received and that activated the trigger. You might want to match all
lines that contain a certain word (such as your character's name) and
print these lines (or part of these lines) in a different color to
draw attention. And sometimes you might want to omit some lines, such
as everything said by some annoying player, or some messages that are
not relevant for you. This kind of trigger is often called a
<emphasis>gag</emphasis>. Both these features are supported by
KildClient.</para>
<para>Triggers are defined by specifying a
<emphasis>pattern</emphasis> against which all lines received from the
MUD are matched. If there is indeed a match, an
<emphasis>action</emphasis> specified by you is executed. If the
trigger is a <emphasis>gag</emphasis>, then the line that matched will
not be printed in the screen, otherwise it is printed normally. (Note
that printing actually happens before the action is executed, even if
here things were described in another order for ease of
understanding.)</para>
<para>The above description was very brief and was meant just to give
a basic idea of how triggers work. Next follows a more detailed
explanation of all aspects involving triggers.</para>
<sect1><title>Creating and Editing Triggers</title>
<para>The easiest way to create and alter triggers is from the World
Editor, the place where all settings of a World are altered (see <xref
linkend="chap:world_editor"/>).</para>
<para>Trigger are defined in the <guilabel>Triggers</guilabel> section
inside the <guilabel>Automation</guilabel> section. When you open that
section, you'll see a list of the defined triggers and some buttons
like this:</para>
<figure><title>The graphical Trigger editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_triggers.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The graphical Trigger editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The main part of the window is the list of defined triggers. The
columns are as follows:</para>
<itemizedlist>
<listitem><para><guilabel>Enabled</guilabel> specifies whether the
trigger is enabled or not. Triggers that are not enabled are not
active and will not be tried when a line is received, but they
remain in the list so that they can later be enabled
again.</para></listitem>
<listitem><para><guilabel>Name</guilabel> is a name that is assigned
to a trigger. This helps you identify the trigger's purpose and is
useful when editing a trigger via the command line (as described in
<xref linkend="sec:edit_trigger_cmdline"/>). Assigning a name to a
trigger is optional.</para></listitem>
<listitem><para><guilabel>Pattern</guilabel> and
<guilabel>Action</guilabel> are the parameters for the trigger, and
they define the trigger's action, as described
above.</para></listitem>
<listitem><para><guilabel>I Case</guilabel> (for "Ignore Case"), if
set, means the case is not considered while matching the pattern,
that is, a case-insensitive match is done.</para></listitem>
<listitem><para><guilabel>Gag</guilabel> defines if the line that
matches the trigger will be printed. If this is active, the line is
gaged (omitted) from the main screen.</para></listitem>
<listitem><para><guilabel>Gag Log</guilabel> defines if the line
that matches the trigger will be written to the log file. If this is
active, the line is gaged (omitted) from the log file, if logging is
enabled (see <xref linkend="chap:logging"/>.</para></listitem>
<listitem><para><guilabel>Keep Exec</guilabel> defines what happens
when the trigger is matched. By default, if a trigger matches
further matching of that line against other triggers is stopped. If,
however, this option is active and the trigger matches, the line
continues being tried against other triggers.</para></listitem>
<listitem><para><guilabel>Rewriter</guilabel> defines if the trigger
is a <emphasis>rewriter</emphasis> trigger, a special kind of
trigger described in <xref
linkend="sec:trigger_rewriter"/>.</para></listitem>
<listitem><para><guilabel>Plugin</guilabel>: if this is non-empty,
it means that the trigger belongs to a plugin (and the name of the
plugin is displayed). However, by default plugin triggers are not
displayed. See <xref linkend="sec:we_advanced"/> for information on
how to display plugin triggers here.</para></listitem>
</itemizedlist>
<sect2 id="sec:add_trigger_gui"><title>Adding Triggers</title>
<para>To add a new trigger, press the <guilabel>Add</guilabel> button.
This will open a window for you to edit the new trigger's parameters:</para>
<figure><title>The window to edit triggers</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_trigger_edit.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to edit triggers.</phrase>
</textobject>
</mediaobject>
</figure>
<para>What can be set represents the columns described above.</para>
<para>When you are finished, press <guilabel>OK</guilabel> and the
trigger will be added. If you change your mind, press
<guilabel>Cancel</guilabel> and the trigger will not be added.</para>
<para>To see some things triggers can do, read <xref
linkend="sec:trigger_cmdline"/>. If you want to try the triggers
described there, you can create them from the World Editor.</para>
</sect2>
<sect2><title>Altering Triggers</title>
<para>To edit a trigger, select it by clicking its line in the list
(the line will be highlighted), and press the
<guilabel>Edit</guilabel> button. A window like the one used for
adding trigger (see <xref linkend="sec:add_trigger_gui"/>) will be
opened, filled with the trigger's parameters. Change what you want,
and press the <guilabel>OK</guilabel> to commit the changes. If,
however, you change you mind, press <guilabel>Cancel</guilabel> and
the changes will be not be made, the trigger will remain as it was
before.</para>
<para>Another shorter way to edit a trigger is to double click its
line in the list.</para>
<para>It is also possible to change the value of the binary options
(those represented by a check box) directly from the trigger list.
Make sure that the trigger you want to change is selected, and click
in the check button. The state will be toggled.</para>
<para>To delete a trigger, select it and press the
<guilabel>Delete</guilabel> button. You will be asked for
confirmation, and can cancel the operation, but once deleted, you
cannot recover the trigger. If you want, you can disable this
confirmation dialog, but if you do so and click the
<guilabel>Delete</guilabel> button, the only way to undo your action
will be creating the trigger again. See <xref
linkend="sec:we_advanced"/>. To delete several triggers at once,
select them all and press <guilabel>Delete</guilabel>.</para>
<para>The final thing that needs to be explained with regard to
triggers is how to reorder them. Triggers as tried from the first one
to the last, so in a few cases the order might matter. To move a
trigger up or down in the list, select it and press the corresponding
button.</para>
</sect2>
</sect1>
<sect1 id="sec:trigger_highlight">
<title>Changing the Style of the Matched Text</title>
<para>It is possible to cause a trigger to change the style of the
line that matched (or of a part of it). This can be used, for example,
to make some text that interests you stand out.</para>
<para>To do that, enable the <guilabel>Change Style</guilabel> check
box in the Edit Trigger dialog (see <xref
linkend="sec:add_trigger_gui"/>). The <guilabel>Configure</guilabel>
button then allows you to set the style to be applied. When pressed,
it brings up a window like this:</para>
<figure><title>The window to configure style</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_trigger_highlight.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to configure the style to be applied.</phrase>
</textobject>
</mediaobject>
</figure>
<para>First you should select what is going to have the style changed.
The style can be applied to the whole line that matched against the
trigger, to the part of the line that matched the trigger pattern, or
the the part of the line that was captured by one of the parentheses
in the pattern (if they are used, naturally).</para>
<para>Next you can configure the style to be applied. You can change
the color of the text, and apply or remove italics, strike-thru and
underlining. In all these options, the default is "<guilabel>Do not
change</guilabel>", which means that the trigger does not affect the
style as sent by the MUD. If you select some option, then your
selection will override the style that the MUD sends.</para>
</sect1>
<sect1 id="sec:trigger_cmdline">
<title>Defining Triggers in the Command Line</title>
<para>For those more used to Perl and to command lines, it is also
possible to define and alter triggers from the command line. This is
done with a series of Perl function.</para>
<para>Triggers are defined with the
<function>$world->trigger</function> function. There are many ways to
use this function, and we will start describing them here.</para>
<para>The simples way to use that function is with two arguments:
<function>$world->trigger(<replaceable>pattern</replaceable>,
<replaceable>action</replaceable>)</function>. This defines a trigger
that will match against <replaceable>pattern</replaceable> and execute
<replaceable>action</replaceable> when a match happens.</para>
<para>What exactly is <replaceable>pattern</replaceable>? It is a
<emphasis>regular expression</emphasis>. If you know Perl, you
certainly know what is a regular expression. If not, it is advised
that you look for some more information on it, there are plenty of
tutorials on the Internet. For those who know them, you can use the
full power of Perl's regular expressions in triggers, because Perl is
used for the matching.</para>
<para>What about the <replaceable>action</replaceable>? It can be
anything that could be entered in the command line. If it is simply a
command, that command will be sent to the MUD. Or you can stack
several commands separating them with <literal>%;</literal> as
described in <xref linkend="sec:interacting"/>.</para>
<para>Here's an example of a very simple trigger:</para>
<example id="ex:simplest_trigger"><title>A very simple trigger</title>
<programlisting>
$world->trigger('has attacked you!', 'wield sword')
</programlisting>
</example>
<para>Whenever a line that contains the phrase "<literal>has attacked
you!</literal>" is received, the command "<userinput>wield
sword</userinput>" will be automatically be sent. Note that in this
case the received line will probably be something like "<literal>An
orc has attacked you!</literal>", but the trigger matches because that
line contains the <replaceable>pattern</replaceable>. This is a
feature of regular expressions. If you want to match the entire line
and not only part of it, you must use the <literal>^</literal> and
<literal>$</literal> anchors in the beginning and end,
respectively.</para>
<para>But the real power is the fact that you can also run Perl
commands in response to triggers. Just enter them as you would in the
command box: prefixed by <literal>/</literal>. If the action is simple
you can enter the statements there directly, if not, you can define a
function in your script file and call it from the trigger.</para>
<para>If the action is a Perl statement, and the
<replaceable>pattern</replaceable> contains bracketed expressions, you
can access the matched text in the brackets with the variables
<varname>$_[1]</varname>, <varname>$_[2]</varname>, and so on. In
<varname>$_[0]</varname> you will find the whole matched line.</para>
<para>Let us rewrite the previous example to be more complex:</para>
<example><title>A trigger with an action in Perl</title>
<programlisting>
$world->trigger('^(.*) has attacked you!$',
'/$world->send("cast missile $_[1]")
</programlisting>
</example>
<para>Now, when a line consisting of some arbitrary text followed by
"<literal>has attacked you!</literal>" is received, the
<function>$world->send</function> will be called to send some text to
the World. This text consists of <userinput>cast missile</userinput>
followed by the text that was before "<literal>has attacked
you!</literal>", which is presumably the name of a mob. So if the
received line is "<literal>Sauron has attacked you!</literal>", the
command that will be sent is "<userinput>cast missile
Sauron</userinput>".</para>
<para>If you call a sub-routine as the trigger action, the matched
arguments are not automatically passed, so you need to pass them
manually. Since they are in the array <varname>@_</varname>, just pass
that whole array as the argument to the sub-routine. Inside the
sub-routine, they will be available as the sub-routine's arguments,
which incidentally means that they will be accessed in the exact same
way: with <varname>$_[1]</varname>, <varname>$_[2]</varname> and so
on.</para>
<para>Here's an example of a trigger that calls a sub-routine:</para>
<example><title>A trigger that calls a sub-routine</title>
<programlisting>
$world->trigger('^(.*) has attacked you!$',
'/myGreatAttackSequence(@_)')
</programlisting>
</example>
<para>Naturally, you need to define the
<function>myGreatAttackSequence</function> sub-routine in your script
file. It will be called as the result of the trigger. The
<varname>@_</varname> array, containing the whole matched line and the
matched bracketed expressions is passed to the sub-routine as argument,
and its contents will be available to the sub-routine as its
paramenters.</para>
<sect2><title>Advanced Features of Triggers</title>
<para>Now that the basic usage of triggers has been explained, let us
see some more advanced features, which will require some small changes
in the way the <function>trigger</function> function is called.</para>
<para>In KildClient, gags are just triggers that are marked as such,
and they behave just like other triggers, with the exception that the
line that matched the pattern does not get printed in the screen. It
is possible to have a gag that executes an action when triggered, just
like with non-gag triggers, or it can be a simple gag, which prevents
the line from being printed but does nothing else.</para>
<para>To specify that a trigger is a gag when it is created an extra
argument is passed to the <function>trigger</function> function. For
those that know Perl, it is a reference to a hash, and this hash can
contain some attributes specifying the trigger's behaviour. For those
that do not understand the previous sentence, do not worry, the
examples should make the usage clear.</para>
<para>Let's create a simple gag to omit all that is said by Joe, a
very silly and annoying player:</para>
<example><title>A simple gag</title>
<programlisting>
$world->trigger('^Joe chats',
'/$world->echonl("Joe said something silly here.")',
{ gag => 1 })
</programlisting>
</example>
<para>See the difference? There is a third parameter, enclosed in
curly braces <literal>{}</literal>, with the word
<literal>gag</literal>, an arrow, and the number 1. What that means is
that <literal>gag</literal> has the value 1, or, as usual in computer
languages, is true. (False would be zero.) The trigger is a gag, and
whenever a line starting with "<literal>Joe chats</literal>" is
received, it will not be printed. Instead, the code specified in the
action will be executed, and that will print a message that tells you
that Joe said something, but does not tell what, so you do not need to
worry.</para>
<para>That is good, but can get even better. We do not need to know
that Joe said something, it would be better if we could ignore him
altogether. And we can. It is not necessary to specify an action for a
gag. In this case, nothing will be done, but the matched line will not
be printed. So our example becomes:</para>
<example><title>A gag with no action</title>
<programlisting>
$world->trigger('^Joe chats',
{ gag => 1 })
</programlisting>
</example>
<para>The action has simply been omitted, but the argument that
specifies that we are dealing with a gag remains, naturally. As a
matter of fact, this kind of gag (with no action) is quite common, and
there is a shorter way to do that. The command below has the exact
same effect as the previous one:</para>
<example><title>A shortcut function to define gags</title>
<programlisting>
$world->gag('^Joe chats')
</programlisting>
</example>
<para>Sometimes you want to change the way a line is displayed, such
as highlighting it or part of it, or rearranging the information so
that it appears in another way. The way to do that is with a gag, and
an action that outputs the modified line. Heres a simple example that
changes the way a hypothetical chat channel is displayed:</para>
<example><title>Rewriting a line with gags</title>
<programlisting>
$world->trigger('^(.*) chats, \'(.*)\'',
'/$world->echonl("[Chat] $_[1]: $_[2]")',
{ gag => 1 })
</programlisting>
</example>
<para>Remember that <varname>$_[0]</varname>, the first element of the
array <varname>@_</varname> contains the whole matched line, with ANSI
codes stripped. If you need the original string including ANSI codes,
you can find them in the variable <varname>$colorline</varname>. A
useful function you should check is <function>colorize</function> (see
<xref linkend="func:colorize" endterm="func:colorize.title"/>), which
allows easy printing of colored strings.</para>
<para>The <literal>gag</literal> attribute only controls whether the
line is displayed in the screen or not. If you have logging enabled
(see <xref linkend="chap:logging"/>), a the line that matched a
trigger with the <literal>gag</literal> attribute will be written in
the log file normally. If you want the line to be omitted from the log
file, you must set also the <literal>gaglog</literal> attribute. If it
is set, then the line will not be written to the log file. Note that
the two attributes are independent: you can gag the line from the
screen, from the log file, from both or from neither.</para>
<para>To make case be ignored when matching, use a very similar
construct as the above, but using the <literal>ignorecase</literal>
attribute:</para>
<example><title>A case-insensitive trigger</title>
<programlisting>
$world->trigger('^.* chats ".*joe.*"', '/callAttention()',
{ ignorecase => 1})
</programlisting>
</example>
<para>Another attribute that can be set for triggers is
<literal>keepexecuting</literal>. By default when a trigger matches,
no more checking is done. So if a line would match two or more
triggers, only the first would have a successful match and have its
action executed. The other ones wouldn't even have a chance to try a
match.</para>
<para>When a trigger has the <literal>keepexecuting</literal> flag
set, even if it matches it does not prevent other triggers from being
tried. So, if a second trigger matches, the actions of both will be
executed. Note, however, that unless this second trigger also has the
<literal>keepexecuting</literal> flag, trigger matching will
stop.</para>
<para>This flag is specified just like <literal>gag</literal>. Just
add the parameter <literal>{ keepexecuting => 1 }</literal> to the
function call. It is possible for a trigger to be both a gag and have
the <literal>keepexecuting</literal> flag. In this case, include both
in the last argument: <literal>{ gag => 1, keepexecuting => 1
}</literal>. Note it is just one argument, with both flags separated
by a comma. The order does not matter,
<literal>keepexecuting</literal> could have come before
<literal>gag</literal>.</para>
<para>If you are having trouble with triggers and want to be informed
whenver a trigger matches, enable the
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Debug Matches</guimenuitem>
</menuchoice>
menu. When this is enabled, information about each matched trigger
will be printed to stderr. (This means you must start KildClient from
a terminal to see the output.)</para>
</sect2>
<sect2 id="sec:trigger_rewriter"><title>Rewriter Triggers</title>
<para>Rewriter triggers are a special kind of trigger that allows
something not possible with ordinary triggers: changing the received
line so that futher triggers work on this changed line.</para>
<para>As mentioned above, the <varname>$colorline</varname> variable
holds the entire line that matched the trigger, including ANSI color
codes. Rewriter triggers can alter this variable, and then the other
triggers will match on this changed line.</para>
<para>Rewriter triggers run before normal triggers. Also, the
<literal>keepexecuting</literal> flag is not considered for them: they
never stop processing of other triggers, even if
<literal>keepexecuting</literal> is not set. The
<literal>gag</literal> and <literal>gaglog</literal> flags are also
not significant for a rewriter trigger, and they are ignore.</para>
<para>Let's see an example of where rewriter triggers can be useful.
Suppose you do not want to see an offensive word that might appear in
the MUD. A first attempt at filtering could be a trigger like
this:</para>
<example>
<title>A profanity filter, that unfortunately does not work</title>
<programlisting>
$world->trigger('fuck',
'/$colorline =~ s/fuck/f***/; $world->echo($colorline)',
{ gag => 1 })
</programlisting>
</example>
<para>This works for simple cases, but it is most likely not what you
want. Suppose you have a trigger that captures messages sent from a
specific channel (such as the one for telepathic communications) and
does something, such as changing the presentation of the message or
sending them to another window. If someone sends a message over that
channel with the f-word, the channel-capture trigger will not work
because the line has already been caught the the profanity-filter
trigger above. You'll see the message with the bad word filtered, but
it will not be captured as a channel message.</para>
<para>You might think about setting the
<literal>keepexecuting</literal> flag in the profanity-filter trigger,
but that would not solve the problem. That trigger would match, and
print in the main window the line just with the word filtered. And
then the original line would match against the channel-capture
trigger, thus acting upon the channel message, but with the bad word
intact, because the trigger did not change the line. So you would end
up seeing the message twice, but neither case in the way you
want.</para>
<para>The solution to this problem is to use a rewriter trigger to
filter the bad word before other triggers have a chance to see the
line. Our profanity-filter trigger should be like this:</para>
<example>
<title>A profanity filter using a rewriter trigger</title>
<programlisting>
$world->trigger('fuck',
'/$colorline =~ s/fuck/f***/',
{ rewriter => 1 })
</programlisting>
</example>
<para>Note that the line is not printed. Rewriter triggers generally
need not print anything, because if no other trigger matches the line,
it will be printed (with the changed contents). If another trigger
does, let this trigger decide what to do.</para>
<para>Now everything should work: when any line with the f-word is
seen, this word is filtered out and the line is changed. If this was a
channel message, the channel-capture trigger will see the line with
the offensive word filtered and display the message in your special
way without the bad word.</para>
</sect2>
<sect2 id="sec:edit_trigger_cmdline"><title>Editing Triggers</title>
<para>In the previous sections it was shown how to add triggers, but
nothing was told about how to change them after they are defined. This
and other points will be addressed in this section.</para>
<para>Before going into editing, let us see how to get a list of all
triggers that are currently defined for the World. Just use the
<function>$world->listtrigger</function> function without arguments.
You will be presented with a list of the currently defined
triggers.</para>
<para>There are several columns: <computeroutput>Num</computeroutput>
is the number of the trigger. Triggers are numbered sequentially
starting at zero. This number will be useful when we start editing
triggers. Next comes <computeroutput>gag</computeroutput>, which tells
whether the trigger is a gag (for the screen). Next is
<computeroutput>GLo</computeroutput>, which means "Gag from Log", and
shows whether the line is omitted (that is, not written) in the log
file also (if logging is enabled, of course). After that,
<computeroutput>Ena</computeroutput> tells whether the trigger is
enabled. Triggers that are disabled are not matched. This is a nice
way to stop a trigger, but keep it stored for later use. We will see
how to enable and disable triggers later in this section. Next there
is <computeroutput>KeE</computeroutput>, which reports the status of
the <literal>keepexecuting</literal> flag for the trigger. After that,
<computeroutput>IgC</computeroutput> specifies the case is being
ignored. The final two columns list the pattern and action of the
trigger.</para>
<para>The listing produced by <function>$world->listtrigger</function>
is compact, showing all triggers but possibly truncating the pattern
and/or action. If you give a trigger number as argument to
<function>listtrigger</function>, it will display that trigger's
information detailedly.</para>
<para>To edit a trigger, you need to know that trigger's number. (And
that can be discovered with the listing functions just described.) The
same function used to add triggers can also change existing ones, you
just need to pass the trigger number as the first argument.</para>
<para>Calling
<function>$world->trigger(<replaceable>number</replaceable>,
<replaceable>new pattern</replaceable>)</function> changes the pattern
of the trigger with that number. If you want to change the pattern and
action, include the action as a third argument:
<function>$world->trigger(<replaceable>number</replaceable>,
<replaceable>new pattern</replaceable>, <replaceable>new
action</replaceable>)</function>. What if you want to change only the
action? Since passing only one string argument would change the
pattern, this is done in a different way, using the same hash that is
used to pass attributes to the trigger. In brief, this is how you
would change only the action:
<function>$world->trigger(<replaceable>number</replaceable>, { action
=> <replaceable>new action</replaceable> })</function>. Notice that
the action is passed as an attribute inside the curly braces. It is
also possible to change the pattern this way, just use the attribute
<literal>pattern</literal>.</para>
<para>Naturally, it is possible to attributes such as
<literal>gag</literal> or <literal>keepexecuting</literal>. The syntax
is the same, include the new value inside the curly braces. To clear
one of those flags, use the value 0, which means false. The example
below makes trigger number 2 stop being a gag, and at the same time
sets it not to prevent matching of other triggers:</para>
<example><title>Changing several attributes at once</title>
<programlisting>
$world->trigger(2,
{ gag => 0,
keepexecuting => 1 })
</programlisting>
</example>
<para>It is also possible, naturally, to change attributes such as
<literal>pattern</literal> or <literal>action</literal> at the same
time that <literal>gag</literal> or <literal>keepexecuting</literal>
are changed. All these attributes are equal, the only difference is
that since the pattern and action are used much more often, there is a
shorter way of specifying them. But even when you create a trigger you
can use this extended syntax. <xref linkend="ex:simplest_trigger"/>
could be also entered this way, with the exact same results:</para>
<example><title>A very simple trigger, in another way</title>
<programlisting>
$world->trigger({ pattern => 'has attacked you!',
action => 'wield sword'})
</programlisting>
</example>
<para>The final attribute for triggers is <literal>enabled</literal>.
It was mentioned briefly when we described how to list triggers. It
can be set just like the other attributes, and like
<literal>keepexecuting</literal> or <literal>gag</literal> it is
<emphasis>binary</emphasis>, that is, takes the values
<emphasis>true</emphasis> (represented by anything different from 0)
or <emphasis>false</emphasis> (represented by 0). When the value of
this attribute is true (which is the default), the trigger is matched
normally. When it is zero, received lines are not matched against it.
This way, disabling a trigger effectively turns if off, as if it did
not exist, but the trigger is still saved, and can be turned on again
when necessary.</para>
<para>Here's an example of disabling a trigger (number 3 in this
case):</para>
<example><title>Disabling a trigger, the long way</title>
<programlisting>
$world->trigger(3,
{ enabled => 0 })
</programlisting>
</example>
<para>However, there is a shorter way: the
<function>$world->distrigger</function> function disables the trigger
whose number is passed as argument. So the example above can be
rewritten in a shorter way as:</para>
<example><title>Disabling a trigger, the short way</title>
<programlisting>
$world->distrigger(3)
</programlisting>
</example>
<para>The corresponding function
<function>$world->enatrigger</function> enables the specified
trigger.</para>
<para>It is also possible to temporarily disable all triggers. Just
use the menu
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Disable Triggers</guimenuitem>
</menuchoice>
and this will prevent triggers from running. This does not change the
"enabled" status of any triggers, it just prevents all triggers from
running. When you select the menu again, triggers that were enabled
will run again, and those that were disabled will remain
disabled.</para>
<para>There are times when you want to delete a trigger. This is easy
to do, use the <function>$world->deltrigger</function> function. It
takes as argument the number of the trigger you wish to delete. Be
aware that once deleted it is not possible to recover the trigger
(unless you create it again). Many times just disabling the trigger is
a better idea. The second thing to note is that when you delete a
trigger the numbers of the other triggers may change, so be careful
when you try to delete several triggers in sequence.</para>
</sect2>
<sect2><title>Assigning Names to Triggers</title>
<para>It is possible to assign names to triggers. When a trigger has a
name, you can enable, disable, or delete it using its name instead of
its number.</para>
<para>To assign a name to a trigger, specify the
<literal>name</literal> attribute when creating it:</para>
<example><title>Creating a trigger with a name</title>
<programlisting>
$world->trigger('has attacked you!', 'wield sword',
{ name => 'attack' })
</programlisting>
</example>
<para>You can now disable this trigger with
<userinput>$world->distrigger('attack')</userinput>. The name can also
be used in the <function>$world->enatrigger</function>,
<function>$world->deltrigger</function> and
<function>$world->listtrigger</function> functions.</para>
<para>It is also possible to assign a name to an existing trigger.
Just edit it as described in <xref
linkend="sec:edit_trigger_cmdline"/>, passing the
<literal>name</literal> attribute. Use this same process to change the
name of a trigger.</para>
<para>Another feature of trigger names is that several triggers can
have the same name. In this case, all these triggers will be treated
as a single group. The functions above, when passed a trigger name,
will act upon all triggers of the group, that is, on all triggers with
that name.</para>
</sect2>
<sect2><title>Reordering Triggers</title>
<para>Triggers are tried from the first to the last, so in some cases
the order of the triggers matters. It is possible to move a trigger to
another position with the <function>$world->movetrigger</function>
function.</para>
<para>The function takes two parameters: the first is the name or
number of the trigger that you want to move. The second is the new
position that the trigger will take in the list. 0 means move the the
first position. If you specify a negative number or a number greater
than the number of triggers, the trigger will be moved to the end of
the list.</para>
<para>If there are several triggers with the same name, only the first
one found will be moved. And when a trigger is moved, other triggers
might move up or down to accomodate the change.</para>
</sect2>
</sect1>
<sect1 id="sec:import_export"><title>Importing and Exporting</title>
<para>You can export triggers, aliases, macros, timers, permanent
variables and hooks to a file, and them load these objects in another
World. This function is accessed via the World Editor.</para>
<para>To export some items, select them from the list. (You can select
several items by holding the <keysym>Control</keysym> key and
clicking.) Press the <guilabel>Export</guilabel> button, and a dialog
will open for you to select a file name. Select a name, press
<guilabel>Save</guilabel> and the selected items will be saved to the
file.</para>
<para>The export function is accessible from the editors for all
exportable objects (triggers, aliases, macros, timers, permanent
variables and hooks). By default, it only exports one kind of object,
the one currently displayed. But you can export more than one kind of
object to the same file (for example, triggers and aliases, or
aliases, macros and hooks, or even all of them). To do that, select
all the items you want from all the pages in the World Editor. Then,
from any page, select <guilabel>Export</guilabel>. From the dialog
that opens, click <guilabel>Items to export</guilabel>. Several check
boxes will appear. Mark the ones corresponding to the objects you want
to export, and all corresponding selected objects will be
imported.</para>
<para>After you have exported some items, you can import them in
another World, even in another machine. Just open one of the editors
(it doesn't matter which one, you can import triggers even from the
alias editor), and press <guilabel>Import</guilabel>. Select the file
from the dialog, and all items in the file will be imported and will
be included in the current World.</para>
</sect1>
<sect1 id="sec:test_triggers"><title>Testing Triggers</title>
<para>You can test your triggers to see how they would react to text
coming from the MUD. To do so, select the
<menuchoice>
<guimenu>Input</guimenu>
<guimenuitem>Test Triggers</guimenuitem>
</menuchoice>
menu item, or press the <guilabel>Test Triggers</guilabel> button from
the Trigger section of the World Editor.</para>
<para>You will see a dialog like this:</para>
<figure><title>The test triggers window</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/testtriggers.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The test triggers window.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In the first entry box, enter some text to be matched against
the triggers that are defined. This line will be matched as if it came
from the MUD. Then press the <guilabel>Send</guilabel> button to try
the triggers. Matching is done exactly for lines that come from the
server: only enabled triggers are tried, rewriter triggers are tried
first and change the line, the keep executing flag is verified, and so
on.</para>
<para>After pressing <guilabel>Send</guilabel>, the results are shown
in the second half of the window. The number of triggers that matched
is displayed, and also all the commands that would be processed if
that line came from the mud (if any). The line that would be printed
to the main window is also displayed. If any gag trigger matched, that
box will be empty indicating that no line will be printed. If no gag
triggers matched, the line could be different because a rewriter
trigger changed it. However, in most cases the line printed will be
the same as the line received. Finally, you are told if the line would
be written in the log file. If any gag log trigger matched the line,
then it would be omitted.</para>
<para>You can try the triggers against other lines, just enter them
and press <guilabel>Send</guilabel>. Any changes you make to the
triggers are used instantly, just press <guilabel>Send</guilabel>
again to try the same line against the new or changed triggers.</para>
</sect1>
</chapter>
<chapter id="chap:aliases"><title>Aliases</title>
<para>Aliases allow you to define shortcuts for simple commands. For
example, you can define <userinput>df</userinput> to be an alias to
<userinput>drink from fountain</userinput>, and then you can type only
<userinput>df</userinput> in the command line, and <userinput>drink
from fountain</userinput> will be sent to the mud.</para>
<para>However, in KildClient aliases can do much more. They allow you
to rewrite part of the input line. In the example above, what happened
is that <userinput>df</userinput> was replaced by <userinput>drink
from fountain</userinput>. Aliases such as these replace the entire
short command you type by a longer command, but you can also replace
part of the line. If a mob has a really long name, such as
Ingeloakastimizilian, you can define an alias "ing" that is replaced
by "Ingeloakastimizilian", and whenever you type
<userinput>ing</userinput>, even in the middle of another command, it
will be replaced by the full name.</para>
<para>Aliases are implemented as a substitution, just like Perl's
<literal>s///</literal> operator. (As a matter of fact, it
<emphasis>is</emphasis> implemented with <literal>s///</literal>.)
They consist of two parts: a <replaceable>pattern</replaceable> and a
<replaceable>substitution</replaceable>. These are just the two
arguments to the <literal>s///</literal> operator. Each command you
enter is tried against the <replaceable>pattern</replaceable>, and
when it matches the <replaceable>substitution</replaceable> is done.
This is more or less how the alias processing is done:</para>
<programlisting>
$line =~ s/$pattern/$substitution/;
</programlisting>
<para>Supposing <varname>$line</varname> holds the entered command,
<varname>$pattern</varname> the pattern and
<varname>$substitution</varname> the substitution. Then
<varname>$line</varname> is sent to the World, possibly having been
modified.</para>
<para>If you are having trouble with aliases and want to be informed
whenver an alias matches, enable the
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Debug Matches</guimenuitem>
</menuchoice>
menu. When this is enabled, information about each matched alias will
be printed to stderr. (This means you must start KildClient from a
terminal to see the output.)</para>
<sect1><title>Creating and Editing Aliases</title>
<para>The easiest way to create and alter aliases is from the World
Editor, the place where all settings of a World are altered (see <xref
linkend="chap:world_editor"/>).</para>
<para>Aliases are defined in the <guilabel>Aliases</guilabel> section
inside the <guilabel>Automation</guilabel> section. When you open that
section, you'll see a list of the defined aliases and some buttons
like this:</para>
<figure><title>The graphical Alias editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_aliases.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The graphical Alias editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The main part of the window is the list of defined aliases. The
columns are as follows:</para>
<itemizedlist>
<listitem><para><guilabel>Enabled</guilabel> specifies whether the
alias is enabled or not. Aliases that are not enabled are not active
and will not be tried when a command is entered, but they remain in
the list so that they can later be enabled again.</para></listitem>
<listitem><para><guilabel>Name</guilabel> is a name that is assigned
to an alias. This helps you identify the alias' purpose and is
useful when editing an alias via the command line (as described in
<xref linkend="sec:edit_alias_cmdline"/>). Assigning a name to an
alias is optional.</para></listitem>
<listitem><para><guilabel>Pattern</guilabel> and
<guilabel>Substitution</guilabel> are the parameters for the alias,
and they define the alias' action, as described above.</para></listitem>
<listitem><para><guilabel>I Case</guilabel> (for "Ignore Case"), if
set, means the case is not considered while matching the pattern,
that is, a case-insensitive match is done.</para></listitem>
<listitem><para><guilabel>Eval as Perl</guilabel> controls how the
alias is evaluated. This option will be described
later.</para></listitem>
<listitem><para><guilabel>Plugin</guilabel>: if this is non-empty,
it means that the alias belongs to a plugin (and the name of the
plugin is displayed). However, by default plugin aliases are not
displayed. See <xref linkend="sec:we_advanced"/> for information on
how to display plugin aliases here.</para></listitem>
</itemizedlist>
<sect2 id="sec:add_alias_gui"><title>Adding Aliases</title>
<para>To add a new alias, press the <guilabel>Add</guilabel> button.
This will open a window for you to edit the new alias' parameters:</para>
<figure><title>The window to edit aliases</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_alias_edit.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to edit aliases.</phrase>
</textobject>
</mediaobject>
</figure>
<para>What can be set represents the columns described above. The only
thing that needs explanation is the <guilabel>Eval Substitution as
Perl statement</guilabel> option, corresponding to the <guilabel>Eval
as Perl</guilabel> column. As mentioned before, aliases are actually a
substitution, using Perl's <literal>s//</literal> construct. It is
also possible to have aliases that use a <literal>s//e</literal>
construct, that is, whose substitution is actually composed of Perl
statements evaluated when a match is found. When that option is
enabled, the substitution is evaluated as a Perl statement.</para>
<para>When you are finished, press <guilabel>OK</guilabel> and the
alias will be added. If you change your mind, press
<guilabel>Cancel</guilabel> and the alias will not be added.</para>
<para>To see some things aliases can do, read <xref
linkend="sec:alias_cmdline"/>. If you want to try the aliases
described there, you can create them from the World Editor.</para>
</sect2>
<sect2><title>Altering Aliases</title>
<para>To edit an alias, select it by clicking its line in the list
(the line will be highlighted), and press the
<guilabel>Edit</guilabel> button. A window like the one used for
adding aliases (see <xref linkend="sec:add_alias_gui"/>) will be
opened, filled with the alias' parameters. Change what you want, and
press the <guilabel>OK</guilabel> to commit the changes. If, however,
you change you mind, press <guilabel>Cancel</guilabel> and the changes
will be not be made, the alias will remain as it was before.</para>
<para>Another shorter way to edit an alias is to double click its line
in the list.</para>
<para>It is also possible to change the value of the
<guilabel>Enabled</guilabel> and <guilabel>Eval as Perl</guilabel>
flags directly from the alias list. Make sure that the alias you want
to change is selected, and click in the check button. The state will
be toggled.</para>
<para>To delete an alias, select it and press the
<guilabel>Delete</guilabel> button. You will be asked for
confirmation, and can cancel the operation, but once deleted, you
cannot recover the alias. If you want, you can disable this
confirmation dialog, but if you do so and click the
<guilabel>Delete</guilabel> button, the only way to undo your action
will be creating the alias again. See <xref
linkend="sec:we_advanced"/>. To delete several aliases at once, select
them all and press <guilabel>Delete</guilabel>.</para>
<para>The final thing that needs to be explained with regard to
aliases is how to reorder them. Aliases as tried from the first one to
the last, so in a few cases the order might matter. To move an alias
up or down in the list, select it and press the corresponding
button.</para>
</sect2>
</sect1>
<sect1 id="sec:alias_cmdline">
<title>Defining Aliases in the Command Line</title>
<para>For those more used to Perl and to command lines, it is also
possible to define and alter aliases from the command line. This is
done with a series of Perl function.</para>
<para>Aliases are defined with the
<function>$world->alias</function> function. This function works
similarly to <function>$world->trigger</function> (described in
<xref linkend="chap:triggers"/>).</para>
<para>The simplest way to call the function is with two arguments:
<function>$world->alias(<replaceable>pattern</replaceable>,
<replaceable>substitution</replaceable>)</function>. This defines an
alias with the given <replaceable>pattern</replaceable> and
<replaceable>substitution</replaceable>. For example, our
<userinput>df</userinput> alias would be created as follows:</para>
<example><title>A simple alias</title>
<programlisting>
$world->alias('^df$', 'drink from fountain')
</programlisting>
</example>
<para>You might be wondering why we use "<literal>^df$</literal>" and
not only "<literal>df</literal>". Remember that aliases are just
substitutions, and the pattern is a regular expression. If the anchors
(that is, <literal>^</literal> and <literal>$</literal>) were not
present, it would match against <userinput>df</userinput> anywhere in
the line, and substitute this <userinput>df</userinput> even in the
middle of words. <userinput>wonder</userinput> would become
<userinput>wodrink from fountainder</userinput>. At times a behaviour
like this (substituting anywhere) might be desirable, but in our case
we want it to substitute only the whole command
<userinput>df</userinput>, so we use the anchors.</para>
<para>As an example of an alias that does not match only the exact
command, consider this one:</para>
<example><title>A slightly more complex alias</title>
<programlisting>
$world->alias('^gra ', 'chat CONGRATULATIONS, ')
</programlisting>
</example>
<para>Whenever you enter a command that starts with
<userinput>gra</userinput> followed by a space, that part
(<userinput>gra</userinput> and the space) is replaced by the given
pattern. So if you enter <userinput>gra Bob</userinput>, what will be
sent to the MUD is <userinput>chat CONGRATULATIONS,
Bob</userinput>.</para>
<para>Since aliases are just a substitution, you can define bracketed
expressions in the pattern and then use <literal>$1</literal>,
<literal>$2</literal>, and so on in the substitution. Let us increment
the above example to add something to the end. We will need a
bracketed expression:</para>
<example><title>An alias that uses bracketed expressions</title>
<programlisting>
$world->alias('^gra (.*)$', 'chat CONGRATULATIONS, $1!!!')
</programlisting>
</example>
<para>It should be easy to understand. <literal>$1</literal> in the
substituion is replaced by what goes after
<userinput>gra</userinput>.</para>
<sect2><title>Advanced Features of Aliases</title>
<para>As mentioned in <xref linkend="sec:add_alias_gui"/>, aliases
can use a <literal>s//e</literal> construct, that is, whose
substitution is actually composed of Perl statements evaluated when a
match is found.</para>
<para>To use that feature, specify an alias like this:</para>
<example><title>An alias whose substitution is evaluated:</title>
<programlisting>
$world->alias('calc\((.*)\)', 'eval "$1"',
{ perleval => 1})
</programlisting>
</example>
<para>See the difference? There is a third parameter, enclosed in
curly braces <literal>{}</literal>, with the word
<literal>perleval</literal>, an arrow, and the number 1. What that
means is that <literal>perleval</literal> has the value 1, or, as
usual in computer languages, is true. (False would be zero.) This
syntax will be explained in more detail in <xref
linkend="sec:edit_alias_cmdline"/>.</para>
<para>The alias allows you to write something like that:
<userinput>gossip 2+3 = calc(2+3)</userinput> and have the result of
the calculation sent to the MUD. (Or any other Perl statement to be
evaluated, actually.)</para>
<para>To specify a case-insensitive match, use the
<literal>ignorecase</literal> attribute:</para>
<example><title>A case-insensitive alias</title>
<programlisting>
$world->alias('^df$', 'drink from fountain',
{ ignorecase => 1 })
</programlisting>
</example>
</sect2>
<sect2 id="sec:edit_alias_cmdline"><title>Editing Aliases</title>
<para>Before going into editing, let us see how to get a list of all
aliases that are currently defined for the World. Just use the
<function>$world->listalias</function> function without arguments. You
will be presented with a list of the currently defined aliases.</para>
<para>There are four columns: <computeroutput>Num</computeroutput> is
the number of the alias. Aliases are numbered sequentially starting at
zero. This number will be useful when we start editing aliases. After
that, <computeroutput>Ena</computeroutput> tells whether the alias is
enabled. Aliases that are disabled are not tried. This is a nice way
to stop an alias from working, but keep it stored for later use. We
will see how to enable and disable aliases later in this section. The
final two columns list the pattern and substitution of the
alias.</para>
<para>The listing produced by <function>$world->listalias</function>
is compact, showing all aliases but possibly truncating the pattern
and/or substitution. If you give an alias number as argument to
<function>listalias</function>, it will display that alias's
information detailedly.</para>
<para>To edit an alias, you need to know that alias's number. (And
that can be discovered with the listing functions just described.) The
same function used to add aliases can also change existing ones, you
just need to pass the alias number as the first argument.</para>
<para>Calling
<function>$world->alias(<replaceable>number</replaceable>,
<replaceable>new pattern</replaceable>)</function> changes the pattern
of the alias with that number. If you want to change the pattern and
substitution, include the substitution as a third argument:
<function>$world->alias(<replaceable>number</replaceable>,
<replaceable>new pattern</replaceable>, <replaceable>new
substitution</replaceable>)</function>. What if you want to change
only the substitution? Since passing only one string argument would
change the pattern, this is done in a different way. In brief, this is
how you would change only the substitution:
<function>$world->alias(<replaceable>number</replaceable>, {
substitution => <replaceable>new substitution</replaceable>
})</function>. Notice that the substitution is passed as an attribute
inside the curly braces. It is also possible to change the pattern
this way, just use the attribute <literal>pattern</literal>.</para>
<para>One other attribute of aliases is <literal>enabled</literal>. It
was mentioned briefly when we described how to list aliases. It can be
set just like the other attributes and is <emphasis>binary</emphasis>,
that is, takes the values <emphasis>true</emphasis> (represented by
anything different from 0) or <emphasis>false</emphasis> (represented
by 0). When the value of this attribute is true (which is the
default), the alias is tried normally. When it is zero, commands are
not tried against it. This way, disabling an alias effectively turns
if off, as if it did not exist, but the alias is still saved, and can
be turned on again when necessary.</para>
<para>Here's an example of disabling an alias (number 3 in this
case):</para>
<example><title>Disabling an alias, the long way</title>
<programlisting>
$world->alias(3,
{ enabled => 0 })
</programlisting>
</example>
<para>However, there is a shorter way: the
<function>$world->disalias</function> function disables the alias
whose number is passed as argument. So the example above can be
rewritten in a shorter way as:</para>
<example><title>Disabling an alias, the short way</title>
<programlisting>
$world->disalias(3)
</programlisting>
</example>
<para>The corresponding function <function>$world->enaalias</function>
enables the specified alias.</para>
<para>It is also possible to temporarily disable all aliases. Just use
the menu
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Disable Aliases</guimenuitem>
</menuchoice>
and this will prevent aliases from being used. This does not change
the "enabled" status of any aliases, it just prevents all aliases from
being executed. When you select the menu again, aliases that were
enabled will be matched again, and those that were disabled will
remain disabled.</para>
<para>There are times when you want to delete an alias. This is easy
to do, use the <function>$world->delalias</function> function. It
takes as argument the number of the alias you wish to delete. Be aware
that once deleted it is not possible to recover the alias (unless you
create it again). Many times just disabling the alias is a better
idea. The second thing to note is that when you delete an alias the
numbers of the other aliases may change, so be careful when you try to
delete several aliases in sequence.</para>
</sect2>
<sect2><title>Assigning Names to Aliases</title>
<para>It is possible to assign names to aliases. When an alias has a
name, you can enable, disable, or delete it using its name instead of
its number.</para>
<para>To assign a name to an alias, specify the
<literal>name</literal> attribute when creating it:</para>
<example><title>Creating an alias with a name</title>
<programlisting>
$world->alias('^df$', 'drink from fountain',
{ name => 'drink' })
</programlisting>
</example>
<para>You can now disable this alias with
<userinput>$world->disalias('drink')</userinput>. The name can also
be used in the <function>$world->enaalias</function>,
<function>$world->delalias</function> and
<function>$world->listalias</function> functions.</para>
<para>It is also possible to assign a name to an existing alias.
Just edit it as described in <xref linkend="sec:edit_alias_cmdline"/>,
passing the <literal>name</literal> attribute. Use this same process
to change the name of an alias.</para>
<para>Another feature of alias names is that several aliases can have
the same name. In this case, all these aliases will be treated as a
single group. The functions above, when passed an alias name, will act
upon all aliases of the group, that is, on all aliases with that
name.</para>
</sect2>
<sect2><title>Reordering Aliases</title>
<para>Aliases are tried from the first to the last, so in some cases
the order of the aliases matters. It is possible to move an alias to
another position with the <function>$world->movealias</function>
function.</para>
<para>The function takes two parameters: the first is the name or
number of the alias that you want to move. The second is the new
position that the alias will take in the list. 0 means move the the
first position. If you specify a negative number or a number greater
than the number of aliases, the alias will be moved to the end of the
list.</para>
<para>If there are several aliases with the same name, only the first
one found will be moved. And when an alias is moved, other aliases
might move up or down to accomodate the change.</para>
</sect2>
</sect1>
</chapter>
<chapter id="chap:macros"><title>Macros</title>
<para>Macros are, in a way, similar to aliases. They allow you to send
commands to the MUD in an easier way. Aliases allow you to associate
commands with shortcuts (typing a three-letter command to send a much
more complex command, for example). Macros allow you to associate a
command with a keypress. You could associate, for example,
<keysym>F5</keysym> with the command <userinput>drink from
fountain</userinput>, and then you would only need to press
<keysym>F5</keysym> to send that command to the MUD.</para>
<para>The commands need not be complex or big: you could associate the
arrow keys with macros that send movement commands, and you would be
able to move around the MUD using the arrow keys.</para>
<para>Macros consist of a <replaceable>key</replaceable> and an
<replaceable>action</replaceable>. The
<replaceable>action</replaceable> represents what is sent to the MUD
when the macro is run. It can be a single command to send, several
commands separated by <literal>%;</literal>, or something to be
executed by Perl, if it starts with <literal>/</literal>.</para>
<sect1><title>Creating and Editing Macros</title>
<para>The easiest way to create and alter macros is from the World
Editor, the place where all settings of a World are altered (see <xref
linkend="chap:world_editor"/>).</para>
<para>Macro are defined in the <guilabel>Macros</guilabel> section
inside the <guilabel>Automation</guilabel> section. When you open that
section, you'll see a list of the defined macros and some buttons
like this:</para>
<figure><title>The graphical Macro editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_macros.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The graphical Macro editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The main part of the window is the list of defined macros. The
columns are as follows:</para>
<itemizedlist>
<listitem><para><guilabel>Enabled</guilabel> specifies whether the
macro is enabled or not. Macros that are not enabled are not active
and will not be run even if their key is pressed, but they remain in
the list so that they can later be enabled again.</para></listitem>
<listitem><para><guilabel>Name</guilabel> is a name that is assigned
to a macro. This helps you identify the macro's purpose and is
useful when editing a macro via the command line (as described in
<xref linkend="sec:edit_macro_cmdline"/>). Assigning a name to a
macro is optional.</para></listitem>
<listitem><para><guilabel>Key</guilabel> is the key that activates
the macro.</para></listitem>
<listitem><para><guilabel>Action</guilabel> is the action that is
run when the key is pressed.</para></listitem>
<listitem><para><guilabel>Plugin</guilabel>: if this is non-empty,
it means that the macro belongs to a plugin (and the name of the
plugin is displayed). However, by default plugin macros are not
displayed. See <xref linkend="sec:we_advanced"/> for information on
how to display plugin macros here.</para></listitem>
</itemizedlist>
<sect2 id="sec:add_macro_gui"><title>Adding Macros</title>
<para>To add a new macro, press the <guilabel>Add</guilabel> button.
This will open a window for you to edit the new macro's parameters:</para>
<figure><title>The window to edit macros</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_macro_edit.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to edit macros.</phrase>
</textobject>
</mediaobject>
</figure>
<para>What can be set represents the columns described above. To
define the key, press the key combination desired in the text box for
<guilabel>Key</guilabel> and the appropriate key code will be
inserted.</para>
<para>When you are finished, press <guilabel>OK</guilabel> and the
macro will be added. If you change your mind, press
<guilabel>Cancel</guilabel> and the macro will not be added.</para>
<para>To see some things macros can do, read <xref
linkend="sec:macro_cmdline"/>. If you want to try the macros described
there, you can create them from the World Editor.</para>
</sect2>
<sect2><title>Altering Macros</title>
<para>To edit a macro, select it by clicking its line in the list
(the line will be highlighted), and press the
<guilabel>Edit</guilabel> button. A window like the one used for
adding macro (see <xref linkend="sec:add_macro_gui"/>) will be
opened, filled with the macro's parameters. Change what you want,
and press the <guilabel>OK</guilabel> to commit the changes. If,
however, you change you mind, press <guilabel>Cancel</guilabel> and
the changes will be not be made, the macro will remain as it was
before.</para>
<para>Another shorter way to edit a macro is to double click its
line in the list.</para>
<para>It is also possible to change the value of the enabled option
directly from the macro list. Make sure that the macro you want to
change is selected, and click in the check button. The state will be
toggled.</para>
<para>To delete a macro, select it and press the
<guilabel>Delete</guilabel> button. You will be asked for
confirmation, and can cancel the operation, but once deleted, you
cannot recover the macro. If you want, you can disable this
confirmation dialog, but if you do so and click the
<guilabel>Delete</guilabel> button, the only way to undo your action
will be creating the macro again. See <xref
linkend="sec:we_advanced"/>. To delete several macros at once, select
them all and press <guilabel>Delete</guilabel>.</para>
<para>The final thing that needs to be explained with regard to
macros is how to reorder them. Macros as tried from the first one
to the last, so in a few cases the order might matter. To move a
macro up or down in the list, select it and press the corresponding
button.</para>
</sect2>
</sect1>
<sect1 id="sec:macro_cmdline">
<title>Defining Macros in the Command Line</title>
<para>For those more used to Perl and to command lines, it is also
possible to define and alter macros from the command line. This is
done with a series of Perl function.</para>
<para>Macros are set defining, as mentioned above, a
<replaceable>key</replaceable> and an
<replaceable>action</replaceable>. The <replaceable>key</replaceable>
is key keycode for the key you wish to assign the macro to. The
easiest way to get the keycode for a given key is with the
<function>$world->getkeycode</function> function. This function takes
no parameters. When run, it prompts you to press a key, and then
prints the keycode for the key. It also returns the keycode as a
string, so you can save it in a variable and use when defining the
macro.</para>
<para>Here's a way to define a macro:</para>
<example><title>Defining a macro</title>
<screen>
<userinput>/$key = $world->getkeycode</userinput>
<computeroutput>Press a key to get its keycode.</computeroutput>
<replaceable>Press the F5 key</replaceable>
<computeroutput>Key code: F5</computeroutput>
<userinput>/$world->macro($key, 'drink from fountain')</userinput>
</screen>
</example>
<para>The above session shows how to assign <userinput>drink from
fountain</userinput> to the <keysym>F5</keysym> key. Note that
<function>$world->getkeycode</function> prompts you for a key and
prints its keycode. Additionally, the keycode is returned, and it is
stored in the <varname>$key</varname> variable. This variable is used
as the first argument to the <function>$world->macro</function>
function, that takes two arguments: the keycode and the action. We
could have entered <literal>'F5'</literal> directly, but using the
keycode returned by <function>$world->getkeycode</function> is easier
and less error-prone.</para>
<para>That's pretty much all about defining macros. They do not take
arguments, it is all about executing simple commands. Other things
that could be done are executing several commands (separating them
with <literal>%;</literal>) or executing a Perl statement or
function.</para>
<sect2 id="sec:edit_macro_cmdline"><title>Editing Macros</title>
<para>Before going into editing, let us see how to get a list of all
macros that are currently defined for the World. Just use the
<function>$world->listmacro</function> function without arguments. You
will be presented with a list of the currently defined macros.</para>
<para>There are four columns: <computeroutput>Num</computeroutput> is
the number of the macro. Macros are numbered sequentially starting at
zero. This number will be useful when we start editing them. After
that, <computeroutput>Ena</computeroutput> tells whether the macro is
enabled. Macros that are disabled are not executed even if the key is
pressed. This is a nice way to stop a macro from working, but keep it
stored for later use. We will see how to enable and disable macros
later in this section. The final two columns list the keycode and
action of the alias.</para>
<para>The listing produced by <function>$world->listmacro</function>
is compact, showing all macros but possibly truncating the keycode
and/or action. If you give a macro number as argument to
<function>listmacro</function>, it will display that macro's
information detailedly.</para>
<para>To edit a macro, you need to know that macro's number. (And that
can be discovered with the listing functions just described.) The same
function used to add macros can also change existing ones, you just
need to pass the macro number as the first argument.</para>
<para>Calling
<function>$world->macro(<replaceable>number</replaceable>,
<replaceable>new keycode</replaceable>)</function> changes the key of
the macro with that number. If you want to change the key and action,
include the substitution as a third argument:
<function>$world->macro(<replaceable>number</replaceable>,
<replaceable>new key</replaceable>, <replaceable>new
action</replaceable>)</function>. What if you want to change only the
action? Since passing only one string argument would change the key,
this is done in a different way. In brief, this is how you would
change only the key:
<function>$world->macro(<replaceable>number</replaceable>, { action =>
<replaceable>new action</replaceable> })</function>. Notice that the
key is passed as an attribute inside the curly braces. It is also
possible to change the key this way, just use the attribute
<literal>key</literal>.</para>
<para>The only attribute for macros, besides the key and action, is
<literal>enabled</literal>. It was mentioned briefly when we described
how to list macros. It can be set just like the other attributes and
is <emphasis>binary</emphasis>, that is, takes the values
<emphasis>true</emphasis> (represented by anything different from 0)
or <emphasis>false</emphasis> (represented by 0). When the value of
this attribute is true (which is the default), the macro is run
normally. When it is zero, even if the key is pressed, the macros is
not run. This way, disabling an alias effectively turns if off, as if
it did not exist, but the macro is still saved, and can be turned on
again when necessary.</para>
<para>Here's an example of disabling a macro (number 3 in this
case):</para>
<example><title>Disabling a macro, the long way</title>
<programlisting>
$world->macro(3,
{ enabled => 0 })
</programlisting>
</example>
<para>However, there is a shorter way: the
<function>$world->dismacro</function> function disables the meacro whose
number is passed as argument. So the example above can be rewritten in
a shorter way as:</para>
<example><title>Disabling a macro, the short way</title>
<programlisting>
$world->dismacro(3)
</programlisting>
</example>
<para>The corresponding function <function>$world->enamacro</function>
enables the specified macro.</para>
<para>It is also possible to temporarily disable all macros. Just use
the menu
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Disable Macros</guimenuitem>
</menuchoice>
and this will prevent macros from running. This does not change the
"enabled" status of any macros, it just prevents all macros from
running. When you select the menu again, macros that were enabled will
run again, and those that were disabled will remain disabled.</para>
<para>There are times when you want to delete a macro. This is easy to
do, use the <function>$world->delmacro</function> function. It takes
as argument the number of the macro you wish to delete. Be aware that
once deleted it is not possible to recover the macro (unless you
create it again). Many times just disabling the macro is a better
idea. The second thing to note is that when you delete a macro the
numbers of the other macros may change, so be careful when you try to
delete several macros in sequence.</para>
</sect2>
<sect2><title>Assigning Names to Macros</title>
<para>It is possible to assign names to macros. When a macro has a
name, you can enable, disable, or delete it using its name instead of
its number.</para>
<para>To assign a name to a macro, specify the <literal>name</literal>
attribute when creating it:</para>
<example><title>Creating a macro with a name</title>
<programlisting>
$world->macro($key, 'drink from fountain',
{ name => 'drink' })
</programlisting>
</example>
<para>You can now disable this macro with
<userinput>$world->dismacro('drink')</userinput>. The name can also be
used in the <function>$world->enamacro</function>,
<function>$world->delmacro</function> and
<function>$world->listmacro</function> functions.</para>
<para>It is also possible to assign a name to an existing macro. Just
edit it as described in <xref linkend="sec:edit_macro_cmdline"/>,
passing the <literal>name</literal> attribute. Use this same process
to change the name of a macro.</para>
<para>Another feature of macro names is that several macros can have
the same name. In this case, all these macros will be treated as a
single group. The functions above, when passed a macro name, will act
upon all macros of the group, that is, on all macros with that
name.</para>
</sect2>
<sect2><title>Reordering Macros</title>
<para>Macros are tried from the first to the last, so in some cases
the order of the macros matters. It is possible to move an macro to
another position with the <function>$world->movemacro</function>
function.</para>
<para>The function takes two parameters: the first is the name or
number of the macro that you want to move. The second is the new
position that the macro will take in the list. 0 means move the the
first position. If you specify a negative number or a number greater
than the number of macros, the macro will be moved to the end of the
list.</para>
<para>If there are several macros with the same name, only the first
one found will be moved. And when an macro is moved, other macros
might move up or down to accomodate the change.</para>
</sect2>
</sect1>
</chapter>
<chapter><title>Timers</title>
<para>Timers allow you to execute commands repeatedly at fixed
intervals, and also to specify a command to be executed later.</para>
<para>Timers have to mandatory attributes: an
<replaceable>interval</replaceable> in seconds, that represents how
often the timer is fired, and an <replaceable>action</replaceable>,
that is the command that is executed. Just like in other places, the
action can be a text that is sent to the MUD, or it can be something
run with Perl.</para>
<para>It is possible to define timers that execute only a fixed number
of times. This is the timer's <replaceable>repeat count</replaceable>.
Whenever the timer is executed, this count is decreased, and when it
reaches zero, the timer is disabled, and will only execute again if
reenabled manually. A timer can also be temporary: in this case, when
the repeat count reaches zero, it is deleted and not only
disabled. A repeat count of -1 means that the timer is executed
indefinitely.</para>
<para>A timer with a repeat count of one is executed only once. Since
the first execution only happens <replaceable>interval</replaceable>
seconds after it is defined, this allows you to define a command to be
executed after some specified time. If it is marked as temporary, the
timer will be deleted after it is run this one time.</para>
<sect1><title>Creating and Editing Timers</title>
<para>The easiest way to create and alter timers is from the World
Editor, the place where all settings of a World are altered (see <xref
linkend="chap:world_editor"/>).</para>
<para>Timer are defined in the <guilabel>Timers</guilabel> section
inside the <guilabel>Automation</guilabel> section. When you open that
section, you'll see a list of the defined timers and some buttons
like this:</para>
<figure><title>The graphical Timer editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_timers.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The graphical Timer editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>The main part of the window is the list of defined timers. The
columns are as follows:</para>
<itemizedlist>
<listitem><para><guilabel>Enabled</guilabel> specifies whether the
timer is enabled or not. Timers that are not enabled are not active
and will not be run, but they remain in the list so that they can
later be enabled again.</para></listitem>
<listitem><para><guilabel>Name</guilabel> is a name that is assigned
to a timer. This helps you identify the timer's purpose and is
useful when editing a timer via the command line (as described in
<xref linkend="sec:edit_timer_cmdline"/>). Assigning a name to a
timer is optional.</para></listitem>
<listitem><para><guilabel>Interval</guilabel> is the interval
between timer activations, as described above.</para></listitem>
<listitem><para><guilabel>Count</guilabel> is the repeat count, as
described above.</para></listitem>
<listitem><para><guilabel>Action</guilabel> is the action that is
run when the timer fires.</para></listitem>
<listitem><para><guilabel>Temp</guilabel> indicates whether the
timer is <emphasis>temporary</emphasis> or not. Temporary timers are
deleted automatically when their repeat count reaches
0.</para></listitem>
<listitem><para><guilabel>Plugin</guilabel>: if this is non-empty,
it means that the timer belongs to a plugin (and the name of the
plugin is displayed). However, by default plugin timers are not
displayed. See <xref linkend="sec:we_advanced"/> for information on
how to display plugin timers here.</para></listitem>
</itemizedlist>
<sect2 id="sec:add_timer_gui"><title>Adding Timers</title>
<para>To add a new timer, press the <guilabel>Add</guilabel> button.
This will open a window for you to edit the new timer's parameters:</para>
<figure><title>The window to edit timers</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_timer_edit.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to edit timers.</phrase>
</textobject>
</mediaobject>
</figure>
<para>What can be set represents the columns described above.</para>
<para>When you are finished, press <guilabel>OK</guilabel> and the
timer will be added. If you change your mind, press
<guilabel>Cancel</guilabel> and the timer will not be added.</para>
<para>To see some things timers can do, read <xref
linkend="sec:timer_cmdline"/>. If you want to try the timers described
there, you can create them from the World Editor.</para>
</sect2>
<sect2><title>Altering Timers</title>
<para>To edit a timer, select it by clicking its line in the list
(the line will be highlighted), and press the
<guilabel>Edit</guilabel> button. A window like the one used for
adding timer (see <xref linkend="sec:add_timer_gui"/>) will be
opened, filled with the timer's parameters. Change what you want,
and press the <guilabel>OK</guilabel> to commit the changes. If,
however, you change you mind, press <guilabel>Cancel</guilabel> and
the changes will be not be made, the timer will remain as it was
before.</para>
<para>Another shorter way to edit a timer is to double click its
line in the list.</para>
<para>It is also possible to change the value of the binary options
(those represented by a check box) directly from the timer list.
Make sure that the timer you want to change is selected, and click
in the check button. The state will be toggled.</para>
<para>To delete a timer, select it and press the
<guilabel>Delete</guilabel> button. You will be asked for
confirmation, and can cancel the operation, but once deleted, you
cannot recover the timer. If you want, you can disable this
confirmation dialog, but if you do so and click the
<guilabel>Delete</guilabel> button, the only way to undo your action
will be creating the timer again. See <xref
linkend="sec:we_advanced"/>. To delete several timers at once, select
them all and press <guilabel>Delete</guilabel>.</para>
<para>The final thing that needs to be explained with regard to
timers is how to reorder them. Timers as tried from the first one
to the last, so in a few cases the order might matter. To move a
timer up or down in the list, select it and press the corresponding
button.</para>
</sect2>
</sect1>
<sect1 id="sec:timer_cmdline">
<title>Defining Timers in the Command Line</title>
<para>For those more used to Perl and to command lines, it is also
possible to define and alter timers from the command line. This is
done with a series of Perl function.</para>
<para>Timers are created with the <function>$world->timer</function>
function. It is similar to other functions for adding triggers,
aliases and macros, but the hash reference with attributes (the thing
inside <literal>{}</literal>) must always be used.</para>
<para>Let us see an example of defining a timer that sends
"<userinput>who</userinput>" once a minute:</para>
<example><title>A simple timer</title>
<programlisting>
$world->timer({ interval => 60,
action => 'who' })
</programlisting>
</example>
<para>Note that the interval is specified in seconds.</para>
<para>Our second example will be of a timer that executes a specified
number of times:</para>
<example><title>A timer that executes only five times</title>
<programlisting>
$count = 5;
$world->timer({ interval => 10,
count => 5,
action => '/$world->send("chat The count is at $count"); --$count' })
</programlisting>
</example>
<para>In these two commands, first a variable that will be used in the
timer is defined. Then the timer is created, specifying
<replaceable>count</replaceable> as 5, so that it is executed only
five times. The timer's action is to send commands counting down to
one. When the count reaches one, the timer is disabled, because it has
already executed five times.</para>
<para>Now let us see a temporary timer:</para>
<example><title>A one-shot timer</title>
<programlisting>
$world->timer({ interval => 30,
count => 1,
temporary => 1,
action => 'say 30 seconds have elapsed' })
</programlisting>
</example>
<para>This timer has a <replaceable>count</replaceable> of one,
meaning it will only be executed once. Also,
<replaceable>temporary</replaceable> is defined as true, which means
that after it is executed (which will happen in 30 seconds), the timer
will be erased.</para>
<para>Of course, a temporary timer does not need to have a
<replaceable>count</replaceable> of one. The countdown timer above
could have been made temporary if it was not needed after it reached
one.</para>
<sect2 id="sec:edit_timer_cmdline"><title>Editing Timers</title>
<para>Before going into editing, let us see how to get a list of all
timers that are currently defined for the World. Just use the
<function>$world->listtimer</function> function without arguments. You
will be presented with a list of the currently defined timers.</para>
<para>There are several columns: <computeroutput>Num</computeroutput>
is the number of the timer. Timers are numbered sequentially starting
at zero. This number will be useful when we start editing timers.
After that, <computeroutput>Int</computeroutput> is the interval (in
seconds) between timer firings. Next comes
<computeroutput>Count</computeroutput>, which is the number of times
the timer will still be fired before being disabled or erased. If the
value is -1, that means that it will execute indefinitely.
<computeroutput>Ena</computeroutput> tells whether the timer is
enabled. enabled. Timers that are disabled are not run. This is a nice
way to stop a timer from working, but keep it stored for later use. We
will see how to enable and disable timer later in this section. After
that, <computeroutput>Temp</computeroutput> tells whether the timer is
temporary or not. Temporary timers were explained in the previous
section. In brief, a temporary timer is deleted (and not only
disabled) after its count reaches zero. The last column shows the
action associated with the timer.</para>
<para>The listing produced by <function>$world->listtimer</function>
is compact, showing all timers but possibly truncating the action. If
you give a timer number as argument to <function>listtimer</function>,
it will display that timer's information detailedly.</para>
<para>To edit a timer, you need to know that timer's number. (And
that can be discovered with the listing functions just described.) The
same function used to add timers can also change existing ones, you
just need to pass the timer number as the first argument.</para>
<para>The generay way to edit a timer is like this:
<userinput>$world->timer(<replaceable>number</replaceable>, {
<replaceable>new attributes</replaceable> })</userinput>, where
<replaceable>new attributes</replaceable> is a list of the attributes
you want to change. For example, the code below changes the interval
of timer number two:</para>
<example><title>Changing the interval of a timer</title>
<programlisting>
$world->timer(2, { interval => 30 })
</programlisting>
</example>
<para>As a further example, consider the one below, that edits timer
number five to be temporary and to run 10 times:</para>
<example><title>Changing the interval of a timer</title>
<programlisting>
$world->timer(5, { temporary => 1,
count => 10 })
</programlisting>
</example>
<para>It is possible to enable and disable timers with the syntax
above, but there is a shorter way: the
<function>$world->distimer</function> function disables the timer
whose number is passed as argument, as shown in the example
below:</para>
<example><title>Disabling a timer, the short way</title>
<programlisting>
$world->distimer(3)
</programlisting>
</example>
<para>The corresponding function <function>$world->enatimer</function>
enables the specified timer.</para>
<para>It is also possible to temporarily disable all timers. Just use
the menu
<menuchoice>
<guimenu>Preferences</guimenu>
<guimenuitem>Disable Timers</guimenuitem>
</menuchoice>
and this will prevent timers from running. This does not change the
"enabled" status of any timers, it just prevents all timers from
running. When you select the menu again, timers that were enabled will
run again, and those that were disabled will remain disabled.</para>
<para>There are times when you want to delete a timer. This is easy to
do, use the <function>$world->deltimer</function> function. It takes
as argument the number of the timer you wish to delete. Be aware that
once deleted it is not possible to recover the timer (unless you
create it again). Many times just disabling it is a better idea. The
second thing to note is that when you delete a timer the numbers of
the other timers may change, so be careful when you try to delete
several timers in sequence.</para>
</sect2>
<sect2><title>Assigning Names to Timers</title>
<para>It is possible to assign names to timers. When a timer has a
name, you can enable, disable, or delete it using its name instead of
its number.</para>
<para>To assign a name to a timer, specify the <literal>name</literal>
attribute when creating it:</para>
<example><title>Creating a timer with a name</title>
<programlisting>
$world->timer({ interval => 60,
action => 'who',
name => 'who' })
</programlisting>
</example>
<para>You can now disable this timer with
<userinput>$world->distimer('who')</userinput>. The name can also be
used in the <function>$world->enatimer</function>,
<function>$world->deltimer</function> and
<function>$world->listtimer</function> functions.</para>
<para>It is also possible to assign a name to an existing timer. Just
edit it as described in <xref linkend="sec:edit_timer_cmdline"/>,
passing the <literal>name</literal> attribute. Use this same process
to change the name of a timer.</para>
<para>Another feature of timer names is that several timers can have
the same name. In this case, all these timers will be treated as a
single group. The functions above, when passed a timer name, will act
upon all timers of the group, that is, on all timers with that
name.</para>
</sect2>
<sect2><title>Reordering Timers</title>
<para>It is possible to move a timer to another position with the
<function>$world->movetimer</function> function.</para>
<para>The function takes two parameters: the first is the name or
number of the timer that you want to move. The second is the new
position that the timer will take in the list. 0 means move the the
first position. If you specify a negative number or a number greater
than the number of timers, the timer will be moved to the end of the
list.</para>
<para>If there are several timers with the same name, only the first
one found will be moved. And when a timer is moved, other timers might
move up or down to accomodate the change.</para>
</sect2>
</sect1>
</chapter>
<chapter id="chap:hooks"><title>Hooks</title>
<para>Hooks allow you to specify an action to be executed
automatically when some events happen. For example, you can define a
hook with actions to be executed when a connection is established, and
then these commands will be automatically executed when you connect to
the World.</para>
<para>You can connect hooks to seven events:</para>
<itemizedlist>
<listitem><para><literal>OnConnect</literal>: This hook is executed
when a connection to the world is made, after the auto-logon has
taken place (if applicable).</para></listitem>
<listitem><para><literal>OnDisconnect</literal>: This hook is executed
when you are disconnected from a World, after the connection has
been closed.</para></listitem>
<listitem><para><literal>OnReceivedText</literal>: Executed when
text is received from the world. The text received is available for
the hook in the <varname>$hookdata</varname> variable, and can be
inspectd in Perl scripts.</para></listitem>
<listitem><para><literal>OnSentCommand</literal>: Executed after a
command is sent to the world. The command is available for the hook
in the <varname>$hookdata</varname> variable, and can be inspectd in
Perl scripts.</para></listitem>
<listitem><para><literal>OnGetFocus</literal>: Executed when the
KildClient window receives the focus.</para></listitem>
<listitem><para><literal>OnLoseFocus</literal>: Executed when the
KildClient window loses the focus.</para></listitem>
<listitem><para><literal>OnCloseDisconnected</literal>: Executed when the
world is forcedly closed. This can happen using the
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Close</guimenuitem>
</menuchoice>
menu, the <function>$world->close()</function> function, or by
quitting the program with the world connected. You can put in this
hook, for example "<userinput>quit</userinput>" to always exit the MUD
nicely, even if you close the world by mistake.</para></listitem>
</itemizedlist>
<sect1><title>Creating and Editing Hooks</title>
<para>The easiest way to create and alter hooks is from the World
Editor, the place where all settings of a World are altered (see <xref
linkend="chap:world_editor"/>).</para>
<para>Hook are defined in the <guilabel>Hooks</guilabel> section
inside the <guilabel>Automation</guilabel> section. When you open that
section, you'll see a list of the defined hooks and some buttons
like this:</para>
<figure><title>The graphical Hook editor</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_hooks.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The graphical Hook editor.</phrase>
</textobject>
</mediaobject>
</figure>
<para>In the top there is a combo box for you to select one of the
five events described above. When an event is selected the hooks
defined for that event will be listed, and all operations will be done
on hooks of that event.</para>
<para>The main part of the window is the list of defined hooks. The
columns are as follows:</para>
<itemizedlist>
<listitem><para><guilabel>Enabled</guilabel> specifies whether the
hook is enabled or not. Hooks that are not enabled are not active
and will not be run, but they remain in the list so that they can
later be enabled again.</para></listitem>
<listitem><para><guilabel>Name</guilabel> is a name that is assigned
to a hook. This helps you identify the hook's purpose and is
useful when editing a hook via the command line (as described in
<xref linkend="sec:edit_hook_cmdline"/>). Assigning a name to a
hook is optional.</para></listitem>
<listitem><para><guilabel>Action</guilabel> defines what is done
when the hook is run..</para></listitem>
</itemizedlist>
<sect2 id="sec:add_hook_gui"><title>Adding Hooks</title>
<para>To add a new hook, select the desired event from the Combo Box
and press the <guilabel>Add</guilabel> button. This will open a window
for you to edit the new hook's parameters:</para>
<figure><title>The window to edit hooks</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_hook_edit.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The window to edit hooks.</phrase>
</textobject>
</mediaobject>
</figure>
<para>What can be set represents the columns described above.</para>
<para>When you are finished, press <guilabel>OK</guilabel> and the
hook will be added. If you change your mind, press
<guilabel>Cancel</guilabel> and the hook will not be added.</para>
<para>To see some things hooks can do, read <xref linkend="sec:hook_cmdline"/>. If you want to try the hooks
described there, you can create them from the World Editor.</para>
</sect2>
<sect2><title>Altering Hooks</title>
<para>To edit a hook, select the event from the combo box, then select
the hook to edit in the list by clicking its line in the list (the
line will be highlighted), and press the <guilabel>Edit</guilabel>
button. A window like the one used for adding hook (see <xref
linkend="sec:add_hook_gui"/>) will be opened, filled with the hook's
parameters. Change what you want, and press the
<guilabel>OK</guilabel> to commit the changes. If, however, you change
you mind, press <guilabel>Cancel</guilabel> and the changes will be
not be made, the hook will remain as it was before.</para>
<para>Another shorter way to edit a hook is to double click its line
in the list.</para>
<para>It is also possible to change the value of enabled setting
directly from the hook list. Make sure that the hook you want to
change is selected, and click in the check button. The state will be
toggled.</para>
<para>To delete a hook, select it and press the
<guilabel>Delete</guilabel> button. You will be asked for
confirmation, and can cancel the operation, but once deleted, you
cannot recover the hook. If you want, you can disable this
confirmation dialog, but if you do so and click the
<guilabel>Delete</guilabel> button, the only way to undo your action
will be creating the hook again. See <xref
linkend="sec:we_advanced"/>. To delete several hooks at once, select
them all and press <guilabel>Delete</guilabel>.</para>
<para>The final thing that needs to be explained with regard to hooks
is how to reorder them. Hooks as run from the first one to the last,
so in a few cases the order might matter. To move a hook up or down in
the list, select it and press the corresponding button.</para>
</sect2>
</sect1>
<sect1 id="sec:hook_cmdline">
<title>Defining Hooks in the Command Line</title>
<para>For those more used to Perl and to command lines, it is also
possible to define and alter hooks from the command line. This is
done with a series of Perl function.</para>
<para>Hooks are defined with the <function>$world->hook</function>
function. This function works similarly to
<function>$world->trigger</function> (described in <xref
linkend="chap:triggers"/>).</para>
<para>The simplest way to call the function is with two arguments:
<function>$world->hook(<replaceable>event</replaceable>,
<replaceable>action</replaceable>)</function>. This defines a hook for
the given event (see above for the valid events) that does
<replaceable>action</replaceable> when the event is fired. As always,
<replaceable>action</replaceable> can be some text or a Perl
action.</para>
<para>Here's an example of connecting a hook to the
<literal>OnConnect</literal> event:</para>
<example><title>Connecting a hook</title>
<programlisting>
$world->hook('OnConnect', 'user Bob %; password 12345')
</programlisting>
</example>
<para>This hook causes the lines to the sent to the MUD when a
connection is established, supposedly representing a way to log in to
some MUD server.</para>
<sect2 id="sec:edit_hook_cmdline"><title>Editing Hooks</title>
<para>Before going into editing, let us see how to get a list of all
hooks that are currently defined for a given event. Just use the
<function>$world->listhook</function> function with the event name as
argument. You will be presented with a list of the currently defined
hooks for that event.</para>
<para>There are three columns: <computeroutput>Num</computeroutput> is
the number of the hook. Hooks are numbered sequentially starting at
zero, but keep in mind that there is a separete numbering for each
event. This number will be useful when we start editing hooks. After
that, <computeroutput>Ena</computeroutput> tells whether the hook is
enabled. Hooks that are disabled are not run. This is a nice way to
stop a hook from working, but keep it stored for later use. We will
see how to enable and disable hook later in this section. The last
column shows the action of the hook.</para>
<para>The listing produced by <function>$world->listhook</function>
is compact, showing all hooks but possibly truncating the pattern
and/or substitution. If you give a hook number or name as the second
argument to <function>listhook</function> (the first argument is the
event, as always), it will display that hook's information
detailedly.</para>
<para>To edit a hook, you need to know that hook's number. (And that
can be discovered with the listing functions just described.) The same
function used to add hooks can also change existing ones, you just
need to pass the hook number as the second argument.</para>
<para>Calling
<function>$world->hook(<replaceable>event</replaceable>,
<replaceable>number</replaceable>, <replaceable>new
action</replaceable>)</function> changes the action of the hook with
that number for that event.</para>
<para>The only attribute for hooks, besides the action is
<literal>enabled</literal>. It was mentioned briefly when we described
how to list hooks. It can be set just like the other attributes and is
<emphasis>binary</emphasis>, that is, takes the values
<emphasis>true</emphasis> (represented by anything different from 0)
or <emphasis>false</emphasis> (represented by 0). When the value of
this attribute is true (which is the default), the hook is tried
normally. When it is zero, commands are not tried against it. This
way, disabling a hook effectively turns if off, as if it did not
exist, but the hook is still saved, and can be turned on again when
necessary.</para>
<para>Here's an example of disabling a hook (number 0 of event
<literal>OnConnect</literal> in this case):</para>
<example><title>Disabling a hook, the long way</title>
<programlisting>
$world->hook('OnConnect', 0,
{ enabled => 0 })
</programlisting>
</example>
<para>However, there is a shorter way: the
<function>$world->dishook</function> function. It takes two
arguments: the event and the hook number, and disables the hook with
the given number. So the example above can be rewritten in a shorter
way as:</para>
<example><title>Disabling a hook, the short way</title>
<programlisting>
$world->dishook('OnConnect', 0)
</programlisting>
</example>
<para>The corresponding function <function>$world->enahook</function>
enables the specified hook.</para>
<para>There are times when you want to delete a hook. This is easy to
do, use the <function>$world->delhook</function> function. It takes as
argument the event and the number of the hook wish to delete. Be aware
that once deleted it is not possible to recover the hook (unless you
create it again). Many times just disabling the hook is a better idea.
The second thing to note is that when you delete a hook the numbers of
the other hook may change, so be careful when you try to delete
several hooks in sequence.</para>
</sect2>
<sect2><title>Assigning Names to Hooks</title>
<para>It is possible to assign names to hook. When a hook has a name,
you can enable, disable, or delete it using its name instead of its
number.</para>
<para>To assign a name to a hook, specify the <literal>name</literal>
attribute when creating it:</para>
<example><title>Creating a hook with a name</title>
<programlisting>
$world->hook('OnConnect', 'user Bob %; password 12345',
{ name => 'connection' })
</programlisting>
</example>
<para>You can now disable this hook with
<userinput>$world->dishook('OnConnect', 'connection')</userinput>.
The name can also be used in the
<function>$world->enahook</function>,
<function>$world->delhook</function> and
<function>$world->listhook</function> functions.</para>
<para>It is also possible to assign a name to an existing hook. Just
edit it as described in <xref linkend="sec:edit_hook_cmdline"/>,
passing the <literal>name</literal> attribute. Use this same process
to change the name of a hook.</para>
<para>Another feature of hook names is that several hooks can have the
same name. In this case, all these hooks will be treated as a single
group. The functions above, when passed a hook name, will act upon all
hooks of the group, that is, on all hooks with that name.</para>
</sect2>
</sect1>
</chapter>
<chapter id="chap:plugins"><title>Plugins</title>
<para>Plugins extend the functionality of KildClient. They add more
features that make the client even more powerful.</para>
<para>Basically, plugins can define triggers, aliases, macros and
timers and/or new functions. Whenever the plugin is loaded, the new
functionality is available.</para>
<para>You can work with plugins from the World Editor (see <xref
linkend="chap:world_editor"/>). Open the World Editor, and select the
<guilabel>Plugins</guilabel> section inside
<guilabel>Automation</guilabel>. You will see a screen like
this:</para>
<figure><title>The Plugin list</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/we_plugins.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>The Plugin list.</phrase>
</textobject>
</mediaobject>
</figure>
<para>There are two lists in the window: one lists the plugins that
are currently loaded and that can be used. The other lists the plugins
in the startup list, which are plugins that are loaded automatically
for you whenever you connect to the World.</para>
<para>To load a plugin, press the <guilabel>Load</guilabel> button. A
dialog will be opened for you to select the file. Select the file and
press <guilabel>Open</guilabel>. The plugin will be loaded and will
appear in the list. Or, if there was a problem and the plugin could
not be loaded, the reason will be given in a message box.</para>
<para>While selecting the file, you have the option to specify that
the plugin is to be loaded always at startup (that is, when you
connect to the World). If you select that option, the plugin will also
be added to the other list.</para>
<para>You can get help for a loaded plugin by selecting its line and
pressing the <guilabel>Help</guilabel> button. Some help describing
how to use the plugin will be shown in the main World window.</para>
<para>You can disable a plugin that is loaded. When a plugin is
disabled, it is turned off temporarily. To disable a plugin, select
its line in the list of loaded plugins and click the check box in the
<guilabel>Enabled</guilabel> column. To enable it back, click in the
check box again.</para>
<para>To add a plugin that is to be loaded always at startup (without
loading it now, or if it is already loaded), press the
<guilabel>Add</guilabel> button after the list of the startup plugins.
A dialog box will open for you to select the file, and if that file
could be loaded, the plugin will be added to the list.</para>
<para>To remove a plugin so that it is not loaded anymore at startup,
select its line and press <guilabel>Remove</guilabel>. And to change
the order that the plugins are loaded, select the line and use the
<guilabel>Up</guilabel> and <guilabel>Down</guilabel> buttons to move
the plugin.</para>
<sect1><title>Loading Plugins from the Command Line</title>
<para>It is also possible to load plugins directly from the command
line, for those more comfortable with it and with Perl.</para>
<para>To load a plugin, the <function>$world->loadplugin</function>
function is used. It must be called with one argument, which can be
either the full path to the file that defines the plugin, or just the
plugin name. But for this to work, the file must be installed in one
of the directories that KildClient looks for plugins. By default, two
locations are searched for: one is the <filename
class="directory">plugins</filename> directory under KildClient's
directory in your HOME path (that is, <filename
class="directory">~/.kildclient/plugins</filename> in UNIX systems).
The other is the <filename role="directory">plugins</filename>
directory under the directory where KildClient stores some of its
files (generally it is something like <filename
class="directory">/usr/local/share/kildclient/plugins</filename>).</para>
<para>For example, here is how to load the <literal>keypad</literal>
plugin (which is a standard plugin distributed with
KildClient):</para>
<example><title>Loading a plugin</title>
<programlisting>
$world->loadplugin('keypad')
</programlisting>
</example>
<para>As an additional example, the code below loads a plugin
specifying its full filename:</para>
<example><title>Loading a plugin specifying the full filename</title>
<programlisting>
$world->loadplugin('/home/joe/kildclient-plugins/attackplugin.pl')
</programlisting>
</example>
<para>Either way, you should see a message saying that the plugin has
been loaded. It is now already working. If the plugin was already
loaded, loading will fail.</para>
<para>To always load the plugin when you connect to the World, either
use the World Editor as described above, or add the line that loads it
to your script file. See <xref linkend="sec:we_scripting"/>.</para>
<sect2><title>Enabling and Disabling Plugins</title>
<para>If you want to turn off a plugin temporarily, you can disable
it. Later, when you want it to work again, just reenable it.</para>
<para>To disable a plugin, use the
<function>$world->displugin</function> function, passing as argument
the name of the plugin. What this function does is disable the
plugin's triggers, aliases, macros and timers. You can still call the
plugin functions directly.</para>
<para>To enable a plugin again, use the
<function>$world->enaplugin</function> function, passing as argument
the name of the plugin.</para>
</sect2>
</sect1>
<sect1><title>Getting Information About Plugins</title>
<para>All plugins should contain a <function>help</function> function
that, when called, prints information about the plugin. If you want to
get help on a plugin, call its <function>help</function> function. The
example below shows how to call the <function>help</function> of the
<literal>keypad</literal> plugin:</para>
<example><title>Getting help about a plugin</title>
<programlisting>
keypad::help()
</programlisting>
</example>
<para>Note that the name of the function is prefixed with the name of
the plugin and <literal>::</literal>. This is a convention so that one
plugin's functions do not interfere with other plugins' ones.</para>
<para>It is possible to get a list of all the currently loaded plugins
with the <function>$world->listplugin</function> function. If called
without arguments, it lists briefly all loaded plugins. But you can
pass as argument either a plugin number or a plugin name, and it will
give more detailed information about that plugin, including a listing
of the triggers, aliases, macros and timers that the plugin defines
(if any).</para>
</sect1>
<sect1><title>Standard Plugins</title>
<para>KildClient comes with a few plugins as part of its distribution.
These plugins will be described here. You can load these plugins as
described above.</para>
<sect2 id="plugin:easypath"><title>easypath</title>
<para>This plugin makes the use of paths (see <xref
linkend="sec:paths"/>) easier. When this plugin is loaded, you can
type <userinput>#2n3e{sw}</userinput> instead of
<userinput>/path("2n3e{sw}")</userinput>.</para>
</sect2>
<sect2 id="plugin:keypad"><title>keypad</title>
<para>This plugin allows use of the keypad for movement. Pressing the
left arrow of the numeric keypad moves to the east, pressing the up
arrow moves to the north, and so on.</para>
<para>A few other keys of the keypad are also bound:
<keysym>-</keysym> and <keysym>+</keysym> represent down and up,
respectively. <keysym>5</keysym> sends <literal>who</literal>,
<keysym>0</keysym> sends <literal>look</literal>, <keysym>/</keysym>
sends <literal>inventory</literal> and <keysym>*</keysym> sends
<literal>score</literal>.</para>
<para>The <keysym>Num Lock</keysym> key must be off for this plugin to
work.</para>
</sect2>
<sect2 id="plugin:notes"><title>notes</title>
<para>This plugin allows you to assign notes to World. The notes are
saved with the World and are restored when it is opened again. You can
write anything you want, probably it will be something you want to
remember for that World.</para>
<para>This plugin requires the gtk2-perl bindings, because it has a
graphical user interface.</para>
<para>Type <userinput>/notes::edit</userinput> to open a window where
you can edit the notes. When you are finished, press the
<guilabel>Close</guilabel> button. The notes are saved
automatically.</para>
<para>Use the <function>notes::clear</function> function to clear the
whole contents of the notes.</para>
<para>It is also possible to append something to the notes with
<function>notes::append('text')</function>. This is probably more
useful in scripts.</para>
</sect2>
<sect2 id="plugin:kc256"><title>kc256</title>
<para>This plugin demonstrates a useful extension to the 16 ansi
colors that KildClient supports. This is the same 256-color extension
supported by xterm (if it is complied with support for that).</para>
<para>With this extension, you can specify any color in a 6x6x6 RGB
color cube, that is, you have 216 rgb colors at your disposal, plus 24
shades of gray. (The remaining 16 colors are the standard ansi
colors.)</para>
<para>There are two functions in this plugin:</para>
<para><function>kc256::showcolors</function>: Displays all 216
available RGB colors and the 24 shades of grey in nice tables, with
the values that you can use in <xref linkend="func:colorize"
endterm="func:colorize.title"/> to access them.</para>
<para><function>kc256::rainbowtext(<parameter>$string</parameter>)</function>:
Just a demonstration on how (not to) use the colors. Displays
<parameter>$string</parameter>, one character in a different
color.</para>
</sect2>
<sect2><title>Other Plugins</title>
<para>The <literal>KCWin</literal> plugin allows you to create general
purpose windows a terminal for output and an entry box for input.
These windows do nothing by themselves, but they can be used by other
plugins when they need a window for input and output.</para>
<para>Since this plugin is just a helper for other plugins, it is not
described here, but rather in <xref linkend="app:KCWin"/>.</para>
<para>The <literal>chat</literal> plugin allows peer to peer chat with
other users of KildClient and of other clients that support the
MudMaster or zChat protocols. It is described in its own chapter,
<xref linkend="chap:chat"/>.</para>
</sect2>
</sect1>
</chapter>
<chapter id="chap:logging"><title>Logging the Output</title>
<para>A useful feature of KildClient is it hability to log all the
output from the MUD, as shown in the screen, so that you can retrieve
it later.</para>
<para>The output is saved in a file you specify. ANSI color codes are
not saved, but otherwise the output is identical.</para>
<para>It is possible to prefix each line with a timestamp, so you can
see when each line was received. You can specify the format of this
timestamp.</para>
<para>Logging is controlled with the
<function>$world->logfile</function> function. The first argument
specifies the path to the file where the output is saved. If the file
already exists, new text will be appended to it.</para>
<para>The second argument, if present, controls the format of the
timestamp. If you do not want a timestamp, then do not pass a second
argument, pass only the file name. This timestamp argument is a string
with control codes. Each control code will be substituted by a part of
the time or date. This sequences are the ones of the
<function>strftime()</function> C function, so see its man page for
the list of control sequences.</para>
<para>Here's an example that turns on logging, with a timestamp that
shows the date and time:</para>
<example><title>Enabling logging</title>
<programlisting>
$world->logfile('/home/bob/mud/mudlog.txt', '%b/%d %H:%M:%S> ')
</programlisting>
</example>
<para>To turn off logging, just call <function>logfile</function> with
no arguments.</para>
<para>There are functions to write arbitrary text to the log file:
<xref linkend="func:writetolog" endterm="func:writetolog.title"/> and
<xref linkend="func:echonlandlog"
endterm="func:echonlandlog.title"/>.</para>
</chapter>
<chapter id="chap:chat"><title>Using the Chat</title>
<para>KildClient supports peer to peer chat (that is, you talk
directly to the other person, and not via a server, be it a MUD server
or a chat server), which allows you to talk to other users of
KildClient or other clients that support the MudMaster or zChat
protocols (both are supported by KildClient).</para>
<para>There are several advantages of chatting directly with the other
person:</para>
<itemizedlist>
<listitem><para>You can chat even if the MUD is down, since the MUD server
is not involved.</para></listitem>
<listitem><para>Since the chat is direct, it cannot be snooped by
immortals or administrators.</para></listitem>
<listitem><para>The chat is independent from the MUD, so you can chat
even if you in a situation in which it would not be possible to talk
through the MUD.</para></listitem>
</itemizedlist>
<para>The chat also supports other features that are not possible
through a MUD, such as snooping a session, that is, seeing everything
the other player sees in the screen (if they allow you to do so, of
course), or sending everything you see to your chat party (if you
allow that, of course), or transfering files.</para>
<para>These features do not pose a security risk, because they can be
disabled and the other person can only see your output if you allow
it, and they can only send files if you allow them to.</para>
<sect1><title>Basic Usage</title>
<para>The chat plugin requires the Gtk2 Perl bindings, and also the
Perl bindings for the vte library. If you cannot load the plugin and
it complains about not finding these bindings, go to <ulink
url="http://http://gtk2-perl.sourceforge.net/">http://gtk2-perl.sourceforge.net/</ulink>
and download them.</para>
<para>To load the plugin, enter
<userinput>/$world->loadplugin('chat')</userinput> in the command
entry box. You should see <literal>Plugin loaded</literal>. If an
error happened, you probably do not have the bindings mentioned in the
above paragraph.</para>
<para>If you want to have the plugin always loaded, you can put that
line (without the slash in the beginning) to your script file, and the
plugin will loaded whenever you open a World.</para>
<para>Now that the plugin is loaded, you have two options: calling
somebody or accepting calls from other persons.</para>
<para>The first thing you should do is set you chat nickname. To do
that, type <userinput>/chat::setname("nickname")</userinput>. You only
need to do this once, as the chat name will be saved and restored when
you open the World again.</para>
<para>To accept calls, enter <userinput>/chat::accept</userinput> in
the command entry box. Other people can now call you. You will need to
give them your IP address. Calls are being waited on port 4050, which
is the default port for the chat protocols. If you want to listen for
connections in another port, just pass that port number as argument,
for example, <userinput>/chat::accept(5000)</userinput>. Be sure to
inform other people the port you are using.</para>
<para>When somebody wants to chat to you, a dialog box will appear
asking if you want to accept the chat. If you want to chat with them,
select <guilabel>Yes</guilabel> to establish the chat connection,
otherwise click <guilabel>No</guilabel> to deny the chat
request.</para>
<para>To call somebody, use the <function>call</function> function:
enter <userinput>/chat::call("host")</userinput>.
<parameter>host</parameter> is the hostname or IP address of the
person you wish to chat with. This command tries connecting to port
4050, if they are using another port, pass that port number as a
second argument to the function.</para>
<para>You can substitute <function>call</function> for
<function>zcall</function>. The later tries using the zChat protocol
instead of the default MudMaster protocol. Use the
<function>zcall</function> function if you know they support the zChat
protocol.</para>
<para>If the other person accepts the chat, the connection will be
established.</para>
<para>Each chat connection has its own window where the text received
is displayed, and with an entry box where you can type messages that
are sent to the other person. To send something, just enter the
message and press <keysym>ENTER</keysym>.</para>
<para>There are some special commands that can be entered in chat windows,
these will be described in the next session.</para>
</sect1>
<sect1><title>Advanced Features</title>
<para>There are other things you can do besides simply chatting. These
functions are accessed by typing some commands in the chat window.
These commands start with <literal>/</literal>, but do not confuse
them with the usage of <literal>/</literal> in the main KildClient
window to run Perl commands.</para>
<para>Here are the commands and their actions:</para>
<variablelist>
<varlistentry><term>/emote <replaceable>text</replaceable></term>
<listitem><para>Sends <replaceable>text</replaceable> as an emote and
not as a chat message, that is, sends a message in the form
<emphasis>name text</emphasis>.</para></listitem>
</varlistentry>
<varlistentry><term>/chatall <replaceable>text</replaceable></term>
<listitem><para>Sends <replaceable>text</replaceable> to all chat
connections.</para></listitem>
</varlistentry>
<varlistentry><term>/emoteall <replaceable>text</replaceable></term>
<listitem><para>Sends <replaceable>text</replaceable> as an emote to
all chat connections.</para></listitem>
</varlistentry>
<varlistentry><term>/group <replaceable>group name</replaceable></term>
<listitem><para>Makes this chat connection a member of the specified
group.</para></listitem>
</varlistentry>
<varlistentry><term>/cg <replaceable>text</replaceable></term>
<listitem><para>Sends <replaceable>text</replaceable> to all
connections that are members of the group that this chat session
belongs.</para></listitem>
</varlistentry>
<varlistentry><term>/eg <replaceable>text</replaceable></term>
<listitem><para>Sends <replaceable>text</replaceable> as an emote to
all connections that are members of the group that this chat session
belongs.</para></listitem>
</varlistentry>
<varlistentry><term>/name <replaceable>nickname</replaceable></term>
<listitem><para>Changes the chat nickname to the one given. This
affects all chat sessions.</para></listitem>
</varlistentry>
<varlistentry><term>/color <replaceable>code</replaceable></term>
<listitem><para>Changes the color used in this chat session to the one
specified. <replaceable>code</replaceable> is a color code as
recognized by the <xref linkend="func:colorize"
endterm="func:colorize.title"/> function. Note that this affects only
chat messages and the text you send, if the chat peer sends messages
in another color, they will be displayed in the color the peer chose.
This affects all chat sessions.</para></listitem>
</varlistentry>
<varlistentry><term>/stripansi</term>
<listitem><para>Strips ANSI color codes in messages received in this
chat. That means that colors sent by the peer will not be displayed,
and that even incoming messages will be displayed in your chat
color.</para></listitem>
</varlistentry>
<varlistentry><term>/nostripansi</term>
<listitem><para>Does not strip ANSI color codes in messages received
in this chat. That means that colors sent by the peer will be
displayed.</para></listitem>
</varlistentry>
<varlistentry><term>/ping</term>
<listitem><para>Pings the other peer. If the connection is alive, they
will reply to this request. Additionally, the time for the reply to be
received is displayed.</para></listitem>
</varlistentry>
<varlistentry><term>/sendfile</term>
<listitem><para>Attemps to send a file to the peer. A dialog will be
displayed for you to select the file to send, and the file will be
offered. If they accept, the file transfer will
start.</para></listitem>
</varlistentry>
<varlistentry><term>/stopfile</term>
<listitem><para>Stops the file transfer currently in
progress.</para></listitem>
</varlistentry>
<varlistentry><term>/snoop</term>
<listitem><para>Asks the peer if you can snoop them, that is, see
everything they see in their MUD session. If they accept, everything
they see will be sent to you and displayed.</para></listitem>
</varlistentry>
<varlistentry><term>/allowsnoop</term>
<listitem><para>Allows the peer to snoop you, that is, they can see
everything you see in your MUD session. Be careful with this command.
By default snooping is not allowed to protect your
privacy.</para></listitem>
</varlistentry>
<varlistentry><term>/noallowsnoop</term>
<listitem><para>Disallows the peer to snoop you, that is, they cannot
see what you see in your MUD session. By default snooping is disabled,
and this command is used to disable it again if you had enabled
it.</para></listitem>
</varlistentry>
<varlistentry><term>/info</term>
<listitem><para>Shows some information about the chat
session.</para></listitem>
</varlistentry>
<varlistentry><term>/hangup</term>
<listitem><para>Stops this chat session. You will need to connect
again to continue talking.</para></listitem>
</varlistentry>
</variablelist>
<para>As you can see, the chat offers much more than simply chatting.
One of its features is file transfer. To send a file, use the
/sendfile command, as descrived above. When your peer wants to send
you a file, a dialog box will be displayed telling you the name and
size of the file. If you want the file, select
<guilabel>Yes</guilabel> and another dialog will be displayed for you
to you can select where to store the file. The file transfer will then
begin. Or you can refuse the file by clicking <guilabel>No</guilabel>.
You can interrupt a file transfer in progress by using the /stopfile
command.</para>
<para>By default, you are prompted whenever somebody wants to talk
with you. If you want to avoid this question and automatically accept
all chats, set the <varname>$chat::auto_accept_calls</varname>
variable to 1 (that is, enter something like
<userinput>/$chat::auto_accept_calls = 1</userinput>). This setting
will be remembered. Set it to 0 to have the prompts again.</para>
<para>If, however, you do not want to chat with anyone, the best thing
is to disable accepting connections. Just type
<userinput>/chat::noaccept</userinput>. Use
<userinput>/chat::acceptcalls</userinput> to accept calls
again.</para>
</sect1>
<sect1><title>Chat Functions</title>
<para>You can also access the chat features via some Perl functions of
the chat plugin. Here is a list of these functions:</para>
<variablelist>
<varlistentry><term><function>chat::call(<parameter>host</parameter>, [<parameter>port</parameter>])</function></term>
<listitem><para>Tries connection to <parameter>host</parameter>, on
port <parameter>port</parameter> (or 4050, if not specified), using
the MudMaster protocol.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::zcall(<parameter>host</parameter>, [<parameter>port</parameter>])</function></term>
<listitem><para>Tries connection to <parameter>host</parameter>, on
port <parameter>port</parameter> (or 4050, if not specified), using
the zChat protocol.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::accept([<parameter>port</parameter>])</function></term>
<listitem><para>Starts listening for chat connections on the given
port (or 4050 if not specified).</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::noaccept()</function></term>
<listitem><para>Stops listening for chat
connections.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::setname(<parameter>nickname</parameter>)</function></term>
<listitem><para>Sets the nickname used in chat
sessions.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::setcolor(<parameter>code</parameter>)</function></term>
<listitem><para>Sets the color used in chat sessions.
<parameter>code</parameter> is a color code as recognized by the <xref linkend="func:colorize" endterm="func:colorize.title"/>
function</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::chat(<parameter>name</parameter>, <parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> to
<parameter>name</parameter>.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::emote(<parameter>name</parameter>, <parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> as an emote to
<parameter>name</parameter>.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::chatall(<parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> to all chat
connections.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::emoteall(<parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> as an emote to all
chat connections.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::group(<parameter>name</parameter>, <parameter>group</parameter>)</function></term>
<listitem><para>Makes the chat connection with
<parameter>name</parameter> a member of the group
<parameter>group</parameter>.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::chatgroup(<parameter>group</parameter>, <parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> to all connections
that are members of the group
<parameter>group</parameter>.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::emotegroup(<parameter>group</parameter>, <parameter>text</parameter>)</function></term>
<listitem><para>Sends <parameter>text</parameter> as an emote to all
connections that are members of the group
<parameter>group</parameter>.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::ping(<parameter>name</parameter>)</function></term>
<listitem><para>Pings the other peer. If the connection is alive, they
will reply to this request. Additionally, the time for the reply to be
received is displayed.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::sendfile(<parameter>name</parameter>, [<parameter>file</parameter>])</function></term>
<listitem><para>Attemps to send a file to the peer. If you do not
specify the file, a dialog will be displayed for you to select the
file to send. The file will be offered. If they accept, the file
transfer will start.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::stopfile(<parameter>name</parameter>)</function></term>
<listitem><para>Stops the file transfer currently in
progress.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::snoop(<parameter>name</parameter>)</function></term>
<listitem><para>Asks <parameter>name</parameter> if you can snoop
them, that is, see everything they see in their MUD session. If they
accept, everything they see will be sent to you and
displayed.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::setallowsnoop(<parameter>name</parameter>, <parameter>value</parameter>)</function></term>
<listitem><para>Sets whether <parameter>name</parameter> can snoop you,
that is, wheter they can see everything you see in your MUD session,
according to <parameter>value</parameter>. By default snooping is
disabled.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::info(<parameter>name</parameter>)</function></term>
<listitem><para>Shows some information about the chat
session.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::setstripansi(<parameter>name</parameter>, <parameter>value</parameter>)</function></term>
<listitem><para>Sets whether to trip ANSI color codes in messages
received from <parameter>name</parameter>, according to
<parameter>value</parameter>. If they are, colors sent by the peer
will not be displayed, and that even incoming messages will be
displayed in your chat color.</para></listitem>
</varlistentry>
<varlistentry><term><function>chat::hangup(<parameter>name</parameter>)</function></term>
<listitem><para>Stops the chat session with
<parameter>name</parameter>. You will need to connect again to
continue talking.</para></listitem>
</varlistentry>
</variablelist>
</sect1>
</chapter>
</part>
<part><title>KildClient Programmer's Reference</title>
<appendix id="app:functions"><title>Global Function Reference</title>
<sect1 id="func:colorize">
<title id="func:colorize.title"><function>colorize</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$color = <function>colorize</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Replaces color codes (see below) in the string with ANSI escape
sequences,so that the string can be echoed in the terminal, for
example. Returns the colorized string.</para>
<para>Color code table (based on colors used by the Smaug
server):</para>
<screen>
&0 (number zero) - Reset all attributes and colors to default
Normal colors:
&x - Black &r - Red
&g - Green &O - Yellow
&b - Blue &p - Magenta
&c - Cyan &w - White
&d - Default foreground
Bold colors:
&z - Bold Black &R - Bold Red
&G - Bold Green &Y - Bold Yellow
&B - Bold Blue &P - Bold Magenta
&C - Bold Cyan &W - Bold White
&D - Default bold foreground
Background colors:
^x - Black ^r - Red
^g - Green ^O - Yellow
^b - Blue ^p - Magenta
^c - Cyan ^w - White
^d - Default background
Light background colors (sometimes causes blinking):
^z - Light Black ^R - Light Red
^G - Light Green ^Y - Light Yellow
^B - Light Blue ^P - Light Magenta
^C - Light Cyan ^W - Light White
^D - Default light background
Attributes: (may not work on other clients)
&_ - Underline on ^_ - All underline off
&= - Double underline on
&| - Strikethrough on ^| - Strikethrough off
&/ - Italics on ^/ - Italics off
&i - Inverse video on ^i - Inverse video off
&h - Hidden mode on ^h - Hidden mode off
</screen>
<para><emphasis>Note</emphasis>: if you want to set both the
foreground and the background, the code for the foreground should come
first. If you want to set the foreground and/or background and one or
more attributes (underline, italics, etc), the attribute settings
should come after the color.</para>
<para><emphasis>Note</emphasis> : to insert a & or ^ character,
use && and ^^, respectively.</para>
<para>You can also also use <function>colorize()</function> to display
text in any color of a 6x6x6 RGB color cube. To do so, use
<literal>&<parameter>r</parameter><parameter>g</parameter><parameter>b</parameter>X</literal>
and ^rgbX to set the foreground and background, respectively.
<parameter>r</parameter>, <parameter>g</parameter>, and
<parameter>b</parameter> are integers between 0 and 5 representing the
amount of red, green and blue. X is really the letter X, it is used to
close the code.</para>
<para>Finally, to select one of the 24 shades of gray available, use
<literal>&<parameter>n</parameter>G</literal> and
<literal>^<parameter>n</parameter>G</literal> for the foreground and
background, respectively, where <parameter>n</parameter> is an integer
from 0 to 23, and G is really the letter G.</para>
<para>You can use the kc256 (see <xref linkend="plugin:kc256"/>)
plugin to display all the colors for you to choose from.</para>
</sect1>
<sect1 id="func:getversion">
<title id="func:getversion.title"><function>getversion</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$version = <function>getversion</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This functions returns the version number of KildClient.</para>
</sect1>
<sect1 id="func:getwindowsize">
<title id="func:getwindowsize.title"><function>getwindowsize</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>($lines, $columns) = <function>getwindowsize</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>$columns = <function>getwindowsize</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This functions returns the current size of the window (in
characters), in terms of lines and columns. It can return both
dimensions, or just the number of columns.</para>
</sect1>
<sect1 id="func:getworld">
<title id="func:getworld.title"><function>getworld</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$var = <function>getworld</function></funcdef>
<paramdef>
<parameter>"name"</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Returns a variable that points to the open world with the given
name. You can then manipulate that world with the returned variable
(by calling functions that operate on worlds with that variable).</para>
<para>For example:</para>
<example id="ex:remote_quit"><title>Quitting from another
world</title>
<programlisting>
$coolmud = getworld("CoolMud");
$coolmud->send("quit");
</programlisting>
</example>
<para>This will send "<userinput>quit</userinput>" to the CoolMud
world.</para>
</sect1>
<sect1 id="func:gotow">
<title id="func:gotow.title"><function>gotow</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>gotow</function></funcdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>gotow</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Focuses the Nth world (when called with a number) or the world
with the given name (when called with a string). The first world is
numbered 0.</para>
</sect1>
<sect1 id="func:help">
<title id="func:help.title"><function>help</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>help</function></funcdef>
<paramdef>
<parameter>"function"</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Displays help for the given function. The name of the function
is passed as a string, so it must be in quotes.</para>
</sect1>
<sect1 id="func:minimize">
<title id="func:minimize.title"><function>minimize</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>minimize</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function minimized KildClient's main window. Called from a
macro, it makes a nice boss key. :-)</para>
</sect1>
<sect1 id="func:path">
<title id="func:path.title"><function>path</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>path</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>str is a string defining a path. The following example shows
the features of paths:</para>
<screen>
3n2e4n2e{ne}e{open door}3n
</screen>
<para>The general syntax syntax is "<literal><number of
repetitions><command></literal>". "<literal><number of
repetitions></literal>" can be omitted, in this case it is considered
as 1. <literal>command</literal> is the command that will be repeated.
If it is not a one-letter command, it should be enclosed in braces
(<literal>{}</literal>).</para>
<para>The example above would generate these commands:</para>
<screen>
n
n
n
e
e
n
n
n
n
e
e
ne
e
open door
n
n
n
</screen>
</sect1>
<sect1 id="func:play">
<title id="func:play.title"><function>play</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>play</function></funcdef>
<paramdef>
<parameter>file</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This function plays a sound file. The argument is the path to
the file.</para>
</sect1>
<sect1 id="func:quit">
<title id="func:quit.title"><function>quit</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>quit</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Disconnects and closes all Worlds and KildClient exits.</para>
</sect1>
<sect1 id="func:stripansi">
<title id="func:stripansi.title"><function>stripansi</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$stripped = <function>stripansi</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Returns the string stripped of any ANSI sequences that it
had.</para>
</sect1>
<sect1 id="func:stripcolorize">
<title id="func:stripcolorize.title"><function>stripcolorize</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$stripped = <function>stripcolorize</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Returns the string stripped of any sequences used by
<xref linkend="func:colorize" endterm="func:colorize.title"/> to add
color to it.</para>
</sect1>
</appendix>
<appendix><title>$world Reference</title>
<para><varname>$world</varname> is a variable that is always present
and points to the current World. It is an object of class
<classname>World</classname>, and is opaque, that is, all interaction
with it should be done via its functions, and not via its
members.</para>
<para>The sections below describe the variables and attributes
available for the <varname>$world</varname> variable.</para>
<sect1 id="var:SILENT">
<title id="var:SILENT.title"><varname>$world->{SILENT}</varname></title>
<para>If this attribute is set to a true value (such as 1), some
messages are not displayed, especifically the messages "Trigger
added", "Trigger modified", "Trigger deleted", "Trigged moved", and
the corresponding messages for the other objects: aliases, macros,
timers, hooks, permanent variables and plugins.</para>
</sect1>
<sect1 id="func:alias">
<title id="func:alias.title"><function>$world->alias</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->alias</function></funcdef>
<paramdef>
<parameter>pattern</parameter>
</paramdef>
<paramdef>
<parameter>substitution</parameter>
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->alias</function></funcdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
<paramdef>
[<parameter>pattern</parameter>
</paramdef>
<paramdef>
[<parameter>substitution</parameter>]]
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Creates a new alias, or edits the alias identified by number.
Entered commands will be matched against pattern (a Perl regular
expression), and if the pattern matches, the given substitution will
be applied. (In a <literal>s/pattern/substitution/</literal>
structure.)</para>
<para>Be careful that any part of the command can match. To match only
the exact string, use something like <literal>'^command$'</literal>.
To match only in the beginning of the line, use
<literal>'^command'</literal>.</para>
<para>Atributes is a reference to a hash defining attributes for
the alias. Generally the call works like this:</para>
<programlisting>
$world->alias("pattern", "action", { attribute1 => value1,
attribute2 => value2, ... })
</programlisting>
<para>Possible attributes:</para>
<itemizedlist>
<listitem><para><literal>pattern</literal>: The pattern to
match.</para></listitem>
<listitem><para><literal>substitution</literal>: The substitution to
do.</para></listitem>
<listitem><para><literal>ignorecase</literal>: If value evaluates to
true, ignore case when matching the pattern.</para></listitem>
<listitem><para><literal>perleval</literal>: If true, the
substitution is made passing the "e" flag
(<literal>s/pattern/substitution/e</literal>), so substitution
should be actually Perl statements to be evaluated when there is a
match.</para></listitem>
<listitem><para><literal>enabled</literal>: If value evaluates to
true, the alias is enabled, if false, it is disabled and commands
are not matched against it.</para></listitem>
<listitem><para><literal>name</literal>: Assigns a name to the
alias, so that it can be referenced by name.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="func:close">
<title id="func:close.title"><function>$world->close</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->close</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Disconnects and closes the current world, immediately.</para>
</sect1>
<sect1 id="func:aliasenabled">
<title id="func:aliasenabled.title">
<function>$world->aliasenabled</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>result = <function>$world->aliasenabled</function></funcdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions checks whether the specified alias exists and
whether it is enabled.</para>
<para>You can pass either a alias number or name. If the alias does
not exist, this function returns <literal>undef</literal>, so you can
distinguish the case of a non-existant alias from a disabled
one.</para>
<para>If the alias exists, then the function returns 0 or 1 depending
on whether it is enabled or not. If you pass a name, and there are
several aliases with the same name, it returns a list with one value
for each alias with that name, and each value is 0 or 1 depending on
the state of the alias.</para>
</sect1>
<sect1 id="func:commandecho">
<title id="func:commandecho.title">
<function>$world->commandecho</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->commandecho</function></funcdef>
<paramdef>
<parameter>boolean</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>$status =
<function>$world->commandecho</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>When used with an argument, this sets the command echo option
for the current world to the given value (which should be false to
cause commands not to be echoed or true to cause them to be
echoed). For more details of the command echo option, see <xref linkend="sec:we_misc"/></para>
<para>If called without arguments, it doesn't change the status of
that option, but returns its current value.</para>
</sect1>
<sect1 id="func:connectother">
<title id="func:connectother.title">
<function>$world->connectother</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->connectother</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function allows you to select another World to connect to,
using the same window. If you are connected, you will be first
disconnected from the current server.</para>
</sect1>
<sect1 id="func:dc">
<title id="func:dc.title"><function>$world->dc</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->dc</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Disconnects from the current world.</para>
</sect1>
<sect1 id="func:delalias">
<title id="func:delalias.title"><function>$world->delalias</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->delalias</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Deletes the alias identified by the given number or name. If
there are several aliases with the same name, deletes them all.</para>
</sect1>
<sect1 id="func:delhook">
<title id="func:delhook.title"><function>$world->delhook</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->delhook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Deletes the hook identified by the given number or name,
connected to the specified event. If there are several hooks with the
same name, deletes them all.</para>
</sect1>
<sect1 id="func:delmacro">
<title id="func:delmacro.title"><function>$world->delmacro</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->delmacro</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Deletes the macro identified by the given number or name. If
there are several macros with the same name, deletes them all.</para>
</sect1>
<sect1 id="func:deltimer">
<title id="func:deltimer.title"><function>$world->deltimer</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->deltimer</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Deletes the timer identified by the given number or name. If
there are several timers with the same name, deletes them all.</para>
</sect1>
<sect1 id="func:deltrigger">
<title id="func:deltrigger.title">
<function>$world->deltrigger</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->deltrigger</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Deletes the trigger identified by the given number or name. If
there are several triggers with the same name, deletes them
all.</para>
</sect1>
<sect1 id="func:disalias">
<title id="func:disalias.title"><function>$world->disalias</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->disalias</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the alias identified by number or name. If there are
several aliases with the same name, disables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:dishook">
<title id="func:dishook.title"><function>$world->dishook</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->dishook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the hook identified by number or name, connected to the
given event. If there are several hooks with the same name, disables
them all. Several arguments can be passed at once.</para>
</sect1>
<sect1 id="func:dismacro">
<title id="func:dismacro.title"><function>$world->dismacro</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->dismacro</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the macro identified by number or name. If there are
several macros with the same name, disables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:displugin">
<title id="func:displugin.title"><function>$world->displugin</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->displugin</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the specified plugin.</para>
</sect1>
<sect1 id="func:distimer">
<title id="func:distimer.title"><function>$world->distimer</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->distimer</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the timer identified by number or name. If there are
several timers with the same name, disables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:distrigger">
<title id="func:distrigger.title">
<function>$world->distrigger</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->distrigger</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Disables the trigger identified by number or name. If there are
several triggers with the same name, disables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:echo">
<title id="func:echo.title"><function>$world->echo</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->echo</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Prints the strings in the terminal window. They are not sent to
the world.</para>
<para>See also <xref linkend="func:echonl" endterm="func:echonl.title"/>, <xref linkend="func:send" endterm="func:send.title"/>.</para>
</sect1>
<sect1 id="func:echonl">
<title id="func:echonl.title"><function>$world->echonl</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->echonl</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Prints the strings in the terminal window, each followed by a
newline. They are not sent to the world.</para>
<para>See also <xref linkend="func:echo" endterm="func:echo.title"/>,
<xref linkend="func:send" endterm="func:send.title"/>.</para>
</sect1>
<sect1 id="func:echonlandlog">
<title id="func:echonlandlog.title"><function>$world->echonlandlog</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->echonlandlog</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This is a convenience function that just calls <xref linkend="func:echonl" endterm="func:echonl.title"/> and <xref linkend="func:writetolog" endterm="func:writetolog.title"/> for each
argument, thus writing the given line(s) to the screen and to the log
file.</para>
</sect1>
<sect1 id="func:enaalias">
<title id="func:enaalias.title"><function>$world->enaalias</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enaalias</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the alias identified by number or name. If there are
several aliases with the same name, enables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:enahook">
<title id="func:enahook.title"><function>$world->enahook</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enahook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the hook identified by number or name, connected to the
given event. If there are several hooks with the same name, enables
them all. Several arguments can be passed at once.</para>
</sect1>
<sect1 id="func:enamacro">
<title id="func:enamacro.title"><function>$world->enamacro</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enamacro</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the macro identified by number or name. If there are
several macros with the same name, enables them all. Several arguments
can be passed at once.</para>
</sect1>
<sect1 id="func:enaplugin">
<title id="func:enaplugin.title"><function>$world->enaplugin</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enaplugin</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the specified plugin.</para>
</sect1>
<sect1 id="func:enatimer">
<title id="func:enatimer.title"><function>$world->enatimer</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enatimer</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the timer identified by number or name. If there are
several timers with the same name, enables them all. Several arguments
can be passed at once.</para>
</sect1>
<sect1 id="func:enatrigger">
<title id="func:enatrigger.title">
<function>$world->enatrigger</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->enatrigger</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Enables the trigger identified by number or name. If there are
several triggers with the same name, enables them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:gag">
<title id="func:gag.title"><function>$world->gag</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->gag</function></funcdef>
<paramdef>
<parameter>pattern</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Adds a gag that prevents lines matching pattern from being
shown.</para>
<para>See the <xref linkend="func:trigger" endterm="func:trigger.title"/> function for more advanced
options.</para>
</sect1>
<sect1 id="func:getconntime">
<title id="func:getconntime.title">
<function>$world->getconntime</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$seconds = <function>$world->getconntime</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function returns the time spent connected to the world, in
seconds.</para>
</sect1>
<sect1 id="func:getentryfont">
<title id="func:getentryfont.title">
<function>$world->getentryfont</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$font = <function>$world->getentryfont</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function returns the name of the font used in the command
entry box.</para>
</sect1>
<sect1 id="func:getidletime">
<title id="func:getidletime.title">
<function>$world->getidletime</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$seconds = <function>$world->getidletime</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function returns the idle time, that is, the time elapsed
since the last command was sent, in seconds. See <xref linkend="sec:we_statusbar"/> for information on how that time is
calculated and how to configure it.</para>
</sect1>
<sect1 id="func:getkeycode">
<title id="func:getkeycode.title">
<function>$world->getkeycode</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$keycode = <function>$world->getkeycode</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>After running this function, press a key (or a combination of
keys). The keycode (to be used in the <xref linkend="func:macro" endterm="func:macro.title"/> function) will be returned and also
printed in the screen.</para>
</sect1>
<sect1 id="func:getmainfont">
<title id="func:getmainfont.title">
<function>$world->getmainfont</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$font = <function>$world->getmainfont</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function returns the name of the font used in the main MUD
window, that is, where the output of the world appears.</para>
</sect1>
<sect1 id="func:getname">
<title id="func:getname.title">
<function>$world->getname</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$name = <function>$world->getname</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function returns the name of the world.</para>
</sect1>
<sect1 id="func:getpluginversion">
<title id="func:getpluginversion.title">
<function>$world->getpluginversion</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$version = <function>$world->getpluginversion</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions returns the version of the plugin with the given
name. If no plugin with that name is loaded, it returns an empty
string.</para>
</sect1>
<sect1 id="func:hook">
<title id="func:hook.title"><function>$world->hook</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->hook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>action</parameter>
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->hook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
<paramdef>
[<parameter>action</parameter>]
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>A hook is an action that is connected to an event, such as
connecting to the World or the window receiving focus. This functions
allow you to define a hook for a given event, that will execute
<parameter>action</parameter>, or to edit the hook identifyed by
<parameter>number</parameter>.</para>
<para>Here are the events currently supported:</para>
<itemizedlist>
<listitem><para><literal>OnConnect</literal>: This hook is execued
when a connection to the world is made, after the auto-logon has
taken place (if applicable).</para></listitem>
<listitem><para><literal>OnDisconnect</literal>: This hook is executed
when you are disconnected from a World, after the connection has
been closed.</para></listitem>
<listitem><para><literal>OnReceivedText</literal>: Executed when
text is received from the world.</para></listitem>
<listitem><para><literal>OnSentCommand</literal>: Executed after a
command is sent to the world. The command is available for the hook
in the <varname>$hookdata</varname> variable, and can be inspectd in
Perl scripts.</para></listitem>
<listitem><para><literal>OnGetFocus</literal>: Executed when the
KildClient window receives the focus.</para></listitem>
<listitem><para><literal>OnLoseFocus</literal>: Executed when the
KildClient window loses the focus.</para></listitem>
<listitem><para><literal>OnCloseDisconnected</literal>: Executed when the
world is forcedly closed. This can happen using the
<menuchoice>
<guimenu>World</guimenu>
<guimenuitem>Close</guimenuitem>
</menuchoice>
menu, the <function>$world->close()</function> function, or by
quitting the program with the world connected. You can put in this
hook, for example "<userinput>quit</userinput>" to always exit the MUD
nicely, even if you close the world by mistake.</para></listitem>
</itemizedlist>
<para><parameter>atributes</parameter> is a reference to a hash
defining attributes for the hook. Generally the call works like
this:</para>
<programlisting>
$world->hook("event", "action", { attribute1 => value1,
attribute2 => value2, ... })
</programlisting>
<para>Possible attributes:</para>
<itemizedlist>
<listitem><para><literal>action</literal>: The action to be
executed.</para></listitem>
<listitem><para><literal>enabled</literal>: If value evaluates to
true, the hook is enabled. If it evaluates to false, the hook
is disbled and is not executed.</para></listitem>
<listitem><para><literal>name</literal>: Assigns a name to the
hook, so that it can be referenced by name.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="func:hookenabled">
<title id="func:hookenabled.title">
<function>$world->hookenabled</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>result = <function>$world->hookenabled</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions checks whether the specified hook exists and
whether it is enabled.</para>
<para>The first argument is the name of the event. For the second, you
can pass either a hook number or name. If the hook does not exist,
this function returns <literal>undef</literal>, so you can distinguish
the case of a non-existant hook from a disabled one.</para>
<para>If the hook exists, then the function returns 0 or 1 depending
on whether it is enabled or not. If you pass a name, and there are
several hooks with the same name, it returns a list with one value for
each hook with that name, and each value is 0 or 1 depending on the
state of the hook.</para>
</sect1>
<sect1 id="func:listalias">
<title id="func:listalias.title">
<function>$world->listalias</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listalias</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Briefly lists all defined aliases.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listalias</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Lists detailedly the alias with the given number or name. If
there are several aliases with the same name, lists them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:listhook">
<title id="func:listhook.title">
<function>$world->listhook</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listhook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This function briefly lists all hooks connected to the given
event.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listhook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Lists detailedly the hook with the given number or name,
connected to the specified event. If there are several hooks with the
same name, lists them all. Several arguments can be passed at
once.</para>
</sect1>
<sect1 id="func:listmacro">
<title id="func:listmacro.title">
<function>$world->listmacro</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listmacro</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Briefly lists all defined macros.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listmacro</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Lists detailedly the macro with the given number or name. If
there are several macros with the same name, lists them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:listpermanent">
<title id="func:listpermanent.title">
<function>$world->listpermanent</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listpermanent</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>This function prints a list of all variables that are defined as
permanent, that is, variables that will be saved when you close the
world and have their values restores when the world is
re-opened.</para>
</sect1>
<sect1 id="func:listplugin">
<title id="func:listplugin.title">
<function>$world->listplugin</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listplugin</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Briefly lists all loaded plugins.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listplugin</function></funcdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Gives detailed information on the given plugin.</para>
</sect1>
<sect1 id="func:listtimer">
<title id="func:listtimer.title">
<function>$world->listtimer</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listtimer</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Briefly lists all defined timers.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listtimer</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Lists detailedly the timer with the given number or name. If
there are several timers with the same name, lists them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:listtrigger">
<title id="func:listtrigger.title">
<function>$world->listtrigger</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listtrigger</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Briefly lists all defined triggers.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->listtrigger</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Lists detailedly the trigger with the given number or name. If
there are several triggers with the same name, lists them all. Several
arguments can be passed at once.</para>
</sect1>
<sect1 id="func:loadplugin">
<title id="func:loadplugin.title">
<function>$world->loadplugin</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$success = <function>$world->loadplugin</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
<funcprototype>
<funcdef>$success = <function>$world->loadplugin</function></funcdef>
<paramdef>
<parameter>file</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Loads a plugin. You can either pass a full path for the file
that defines the plugin, or just its name. If you provide only the
name, a file with that name (and the extesion <filename class="extension">.pl</filename>, if the extension is not already
provided) will be looked for in the directories specified by the
<varname>@PLUGINDIRS</varname> array. By default, this array contain
two directories: one where KildClient stores some of its files
(generally <filename class="directory">/usr/local/share/kildclient/plugins</filename>) and
one in the user's home directory (<filename class="directory">~/.kildclient/plugins</filename>), but feel free to
add more directories to search plugins for.</para>
<para>This function returns true if the plugin was successfully
loaded, and false otherwise (including the case in which the plugin
was already loaded). See also <xref linkend="func:requireplugin" endterm="func:requireplugin.title"/> for a way to load a plugin
unless it is already loaded.</para>
</sect1>
<sect1 id="func:logfile">
<title id="func:logfile.title">
<function>$world->logfile</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->logfile</function></funcdef>
<paramdef>
<parameter>file</parameter>
</paramdef>
<paramdef>
[<parameter>timeformat</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Starts logging to the given file. Everything output by the mud
will be saved. If <parameter>timeformat</parameter> is specified, it
is considered a string to be passed to the C
<function>strftime()</function> function, with special tags that are
replace with the current time and/or date, and the resulting string is
prefixed to each line. (See the strftime manual page for the possible
tags.) If this argument is not given, nothing is prefixed to the
lines.</para>
<para>It is not possible to log to more than one file at one time, if
there is already a log file open, it will be closed and logging will
continue to the new file.</para>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->logfile</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>With no arguments, this function stops logging output.</para>
</sect1>
<sect1 id="func:macro">
<title id="func:macro.title"><function>$world->macro</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->macro</function></funcdef>
<paramdef>
<parameter>keycode</parameter>
</paramdef>
<paramdef>
<parameter>action</parameter>
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->macro</function></funcdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
<paramdef>
[<parameter>keycode</parameter>
</paramdef>
<paramdef>
[<parameter>action</parameter>]]
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Creates a new macro, or edits the macro identified by number.
<parameter>keycode</parameter> represents a key such as
"<literal>KP_Home</literal>" or "<literal><Control>F12</literal>".
The format is the one accepted by the GTK+ function
<function>gtk_accelerator_parse()</function>, but most of the time you
will want to use the <xref linkend="func:getkeycode" endterm="func:getkeycode.title"/> function to retrieve the keycode
for a given key. <parameter>action</parameter> is what will be
executed when the key (or keys) is pressed.</para>
<para>Atributes is a reference to a hash defining attributes for
the macro. Generally the call works like this:</para>
<programlisting>
$world->macro("keycode", "action", { attribute1 => value1,
attribute2 => value2, ... })
</programlisting>
<para>Possible attributes:</para>
<itemizedlist>
<listitem><para><literal>key</literal>: The key code.</para></listitem>
<listitem><para><literal>action</literal>: The action to be
executed.</para></listitem>
<listitem><para><literal>enabled</literal>: If value evaluates to
true, the macro is enabled, if false, it is disabled and is not run
if the key is pressed.</para></listitem>
<listitem><para><literal>name</literal>: Assigns a name to the
macro, so that it can be referenced by name.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="func:macroenabled">
<title id="func:macroenabled.title">
<function>$world->macroenabled</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>result = <function>$world->macroenabled</function></funcdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions checks whether the specified macro exists and
whether it is enabled.</para>
<para>You can pass either a macro number or name. If the macro does
not exist, this function returns <literal>undef</literal>, so you can
distinguish the case of a non-existant macro from a disabled
one.</para>
<para>If the macro exists, then the function returns 0 or 1 depending
on whether it is enabled or not. If you pass a name, and there are
several macros with the same name, it returns a list with one value
for each macro with that name, and each value is 0 or 1 depending on
the state of the macro.</para>
</sect1>
<sect1 id="func:movetimer">
<title id="func:movetimer.title">
<function>$world->movetimer</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->movetimer</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>new_pos</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Moves the timer with the given name or number so that it
occupies the position <parameter>new_pos</parameter> after execution
of this function. Other timers might be moved up or down in result of
this. If <parameter>new_pos</parameter> is negative or greater than
the number of timers, the timer is moved to the last position.</para>
<para>If there are several timers with the given name, only the first
one found is moved.</para>
</sect1>
<sect1 id="func:makepermanent">
<title id="func:makepermanent.title">
<function>$world->makepermanent</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->makepermanent</function></funcdef>
<paramdef>
<parameter>var</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This function marks one or more variables as permanent, that is,
the values of these variables will be saved when the world is closed,
and reloaded when the World is opened, thus keeping their values
between successive uses of the World.</para>
<para>The names of the variables are passed as a string, including the
<literal>$</literal>, <literal>@</literal> or <literal>%</literal>
prefix. Be careful to use single quotes (or <literal>\</literal>
inside double quotes) to avoid variable interpolation.</para>
</sect1>
<sect1 id="func:maketemporary">
<title id="func:maketemporary.title">
<function>$world->maketemporary</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->maketemporary</function></funcdef>
<paramdef>
<parameter>var</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This function marks one or more variables as temporary, that is,
the values of these variables will not be saved when the World is
closed. This is the standard behaviour for variables, so this function
is only needed to undo the efects of the <xref linkend="func:makepermanent" endterm="func:makepermanent.title"/>
function.</para>
<para>The names of the variables are passed as a string, including the
<literal>$</literal>, <literal>@</literal> or <literal>%</literal>
prefix. Be careful to use single quotes (or <literal>\</literal>
inside double quotes) to avoid variable interpolation.</para>
</sect1>
<sect1 id="func:movealias">
<title id="func:movealias.title">
<function>$world->movealias</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->movealias</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>new_pos</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Moves the alias with the given name or number so that it
occupies the position <parameter>new_pos</parameter> after execution
of this function. Other aliases might be moved up or down in result of
this. If <parameter>new_pos</parameter> is negative or greater than
the number of aliases, the alias is moved to the last position.</para>
<para>If there are several aliases with the given name, only the first
one found is moved.</para>
</sect1>
<sect1 id="func:movehook">
<title id="func:movehook.title">
<function>$world->movehook</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->movehook</function></funcdef>
<paramdef>
<parameter>event</parameter>
</paramdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>new_pos</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Moves the hook with the given name or number, connected to the
given event, so that it occupies the position
<parameter>new_pos</parameter> after execution of this function. Other
hooks might be moved up or down in result of this. If
<parameter>new_pos</parameter> is negative or greater than the number
of hooks, the hook is moved to the last position.</para>
<para>If there are several hooks with the given name, only the
first one found is moved.</para>
</sect1>
<sect1 id="func:movemacro">
<title id="func:movemacro.title">
<function>$world->movemacro</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->movemacro</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>new_pos</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Moves the macro with the given name or number so that it
occupies the position <parameter>new_pos</parameter> after execution
of this function. Other macros might be moved up or down in result of
this. If <parameter>new_pos</parameter> is negative or greater than
the number of macros, the macro is moved to the last position.</para>
<para>If there are several macros with the given name, only the first
one found is moved.</para>
</sect1>
<sect1 id="func:movetrigger">
<title id="func:movetrigger.title">
<function>$world->movetrigger</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->movetrigger</function></funcdef>
<paramdef>
<parameter>number/name</parameter>
</paramdef>
<paramdef>
<parameter>new_pos</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Moves the trigger with the given name or number so that it
occupies the position <parameter>new_pos</parameter> after execution
of this function. Other triggers might be moved up or down in result
of this. If <parameter>new_pos</parameter> is negative or greater than
the number of triggers, the trigger is moved to the last
position.</para>
<para>If there are several triggers with the given name, only the
first one found is moved.</para>
</sect1>
<sect1 id="func:next">
<title id="func:next.title">
<function>$world->next</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->next</function></funcdef>
<paramdef>
[<parameter>number</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>If used without arguments, this function focuses the next open
World. You can also give a numeric argument X, in this case it focuses
the Xth World after the current one.</para>
</sect1>
<sect1 id="func:prev">
<title id="func:prev.title">
<function>$world->prev</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->prev</function></funcdef>
<paramdef>
[<parameter>number</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>If used without arguments, this function focuses the previous
open world. You can also give a numeric argument X, in this case it
focuses the Xth world before the current one.</para>
</sect1>
<sect1 id="func:reconnect">
<title id="func:reconnect.title">
<function>$world->reconnect</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->reconnect</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>When in offline mode, this function will attempt to reconnect to
the mud.</para>
</sect1>
<sect1 id="func:requireplugin">
<title id="func:requireplugin.title">
<function>$world->requireplugin</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>$success = <function>$world->requireplugin</function></funcdef>
<paramdef>
<parameter>name</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This function is similar to <xref linkend="func:loadplugin" endterm="func:loadplugin.title"/>, but first checks if the plugin is
already loaded. If it is, it returns successfully. If not, it tries
loading the plugin (silently). If this succeeds, the function returns
successfully, if not, it <function>die</function>()'s. This function
is useful in plugins that require other plugins, and is meant to be
called in a <literal>BEGIN</literal> block of a plugin that requires
another.</para>
<para>The argument passed must be the name of the plugin (a path to
the file is not allowed, unlike with <xref linkend="func:loadplugin" endterm="func:loadplugin.title"/>. See <xref linkend="func:loadplugin" endterm="func:loadplugin.title"/> for
information on how plugins are found.</para>
</sect1>
<sect1 id="func:save">
<title id="func:save.title">
<function>$world->save</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->save</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Saves the current World.</para>
</sect1>
<sect1 id="func:send">
<title id="func:send.title"><function>$world->send</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->send</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sends any number of strings to the current world. After each
string, a newline is send, so that the MUD recognizes it as a
command.</para>
<para>See also <xref linkend="func:echo" endterm="func:echo.title"/>,
<xref linkend="func:sendecho" endterm="func:sendecho.title"/> and
<xref linkend="func:sendnoecho" endterm="func:sendnoecho.title"/>.</para>
</sect1>
<sect1 id="func:sendecho">
<title id="func:sendecho.title"><function>$world->sendecho</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->sendecho</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sends any number of strings to the current world. After each
string, a newline is send, so that the MUD recognizes it as a
command.</para>
<para>The commands are always echoed to the window, regardless of the
setting of the command echo option (see <xref linkend="sec:we_misc"/>).</para>
<para>See also <xref linkend="func:send" endterm="func:send.title"/>
and <xref linkend="func:sendnoecho" endterm="func:sendnoecho.title"/>
.</para>
</sect1>
<sect1 id="func:sendfile">
<title id="func:sendfile.title"><function>$world->sendfile</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->send</function></funcdef>
<paramdef>
<parameter>file</parameter>
</paramdef>
<paramdef>
[<parameter>delay</parameter>
</paramdef>
<paramdef>
[<parameter>n-lines</parameter>]]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sends the contents of the given file to the world.
<parameter>delay</parameter> is the number of seconds to wait between
sending each group of lines, and <parameter>n-lines</parameter> is the
number of lines to send a time. If these values are not specified,
they are taken from the defauls set in the Preferences dialog.</para>
<para>If the file does not exist or cannot be open, this function
simply does nothing.</para>
</sect1>
<sect1 id="func:sendnoecho">
<title id="func:sendnoecho.title"><function>$world->sendnoecho</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->sendnoecho</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sends any number of strings to the current world. After each
string, a newline is send, so that the MUD recognizes it as a
command.</para>
<para>The commands are not echoed to the window, regardless of the
setting of the command echo option (see <xref linkend="sec:we_misc"/>).</para>
<para>See also <xref linkend="func:send" endterm="func:send.title"/>
and <xref linkend="func:sendecho" endterm="func:sendecho.title"/>
.</para>
</sect1>
<sect1 id="func:setstatus">
<title id="func:setstatus.title">
<function>$world->setstatus</function>
</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->setstatus</function></funcdef>
<paramdef>
<parameter>text</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sets the text in the main window status bar to the given
text.</para>
</sect1>
<sect1 id="func:timer">
<title id="func:timer.title"><function>$world->timer</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->timer</function></funcdef>
<paramdef>
<parameter>attributes</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->timer</function></funcdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
<paramdef>
<parameter>attributes</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Creates a new timer, or edits the timer identified by
number.</para>
<para><parameter>atributes</parameter> is a reference to a hash
defining attributes for the timer. Generally the call works like
this:</para>
<programlisting>
$world->timer({ attribute1 => value1,
attribute2 => value2, ... })
</programlisting>
<para>Possible attributes:</para>
<itemizedlist>
<listitem><para><literal>interval</literal>: Number of seconds
between each execution. Required.</para></listitem>
<listitem><para><literal>count</literal>: Number of times to execute
the timer. After this number of executions, the timer will be
automatically disabled or deleted (see <literal>temporary</literal>
flag below). If <literal>count</literal> is not given or
<literal>count</literal> is -1, the timer repeats until manually
disabled or deleted.</para></listitem>
<listitem><para><literal>action</literal>: The action to execute.
Required.</para></listitem>
<listitem><para><literal>temporary</literal>: If set to 1, the timer
will be deleted (and not only disabled) after
<literal>count</literal> executions have happened.</para></listitem>
<listitem><para><literal>enabled</literal>: If set to 1, the timer
is enabled and will execute every <literal>count</literal> seconds.
If set to 0, the timer does not execute until enabled again. New
timers are created enabled by default.</para></listitem>
<listitem><para><literal>name</literal>: Assigns a name to the
timer, so that it can be referenced by name.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="func:timerenabled">
<title id="func:timerenabled.title">
<function>$world->timerenabled</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>result = <function>$world->timerenabled</function></funcdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions checks whether the specified timer exists and
whether it is enabled.</para>
<para>You can pass either a timer number or name. If the timer does
not exist, this function returns <literal>undef</literal>, so you can
distinguish the case of a non-existant timer from a disabled
one.</para>
<para>If the timer exists, then the function returns 0 or 1 depending
on whether it is enabled or not. If you pass a name, and there are
several timers with the same name, it returns a list with one value
for each timer with that name, and each value is 0 or 1 depending on
the state of the timer.</para>
</sect1>
<sect1 id="func:trigger">
<title id="func:trigger.title"><function>$world->trigger</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->trigger</function></funcdef>
<paramdef>
<parameter>pattern</parameter>
</paramdef>
<paramdef>
<parameter>action</parameter>
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->trigger</function></funcdef>
<paramdef>
<parameter>number</parameter>
</paramdef>
<paramdef>
[<parameter>pattern</parameter>
</paramdef>
<paramdef>
[<parameter>action</parameter>]]
</paramdef>
<paramdef>
[<parameter>attributes</parameter>]
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Creates a new trigger, or edits the trigger identified by
<parameter>number</parameter>, matching <parameter>pattern</parameter>
(a Perl regular expression), that will execute
<parameter>action</parameter> when a line is matched by
<parameter>pattern</parameter>. <parameter>action</parameter> is
interpreted as if it were typed in the command box. Simple strings get
sent to the world, Perl code can be run by prefixing it with
'<literal>/</literal>', etc.</para>
<para><parameter>atributes</parameter> is a reference to a hash
defining attributes for the trigger. Generally the call works like
this:</para>
<programlisting>
$world->trigger("pattern", "action", { attribute1 => value1,
attribute2 => value2, ... })
</programlisting>
<para>Possible attributes:</para>
<itemizedlist>
<listitem><para><literal>pattern</literal>: The pattern to
match.</para></listitem>
<listitem><para><literal>action</literal>: The action to be
executed.</para></listitem>
<listitem><para><literal>enabled</literal>: If value evaluates to
true, the trigger is enabled. If it evaluates to false, the trigger
is disbled and lines are not matched against it.</para></listitem>
<listitem><para><literal>name</literal>: Assigns a name to the
trigger, so that it can be referenced by name.</para></listitem>
<listitem><para><literal>ignorecase</literal>: If value evaluates to
true, ignore case when matching the pattern.</para></listitem>
<listitem><para><literal>gag</literal>: If value evaluates to true,
the line that triggered it is not printed.</para></listitem>
<listitem><para><literal>gaglog</literal>: If value evaluates to
true, the line that triggered it is not written to the log
file.</para></listitem>
<listitem><para><literal>keepexecuting</literal>: If the value
evaluates to true, when a line matches the trigger, the actions for
the trigger are executed, and matching of the line continues against
other triggers. If this is false (the default), when this trigger
matches no other triggers are matched.</para></listitem>
<listitem><para><literal>rewriter</literal>:This trigger is a
rewriter trigger. It is run before other triggers, does not prevent
any other trigger from running (even if keepexecuting is false), and
can alter the input line for further processing by changing the
<varname>$colorline</varname> variable. For more details, see <xref
linkend="sec:trigger_rewriter"/>.</para></listitem>
<listitem><para><literal>style</literal>: Used to control the
changing of styles (color, attributes, etc.) of a matched part of
the line. The value of this attribute is an anonymous hash that
specifies everything that is to be changed.</para>
<para>Here's an example:</para>
<example id="ex:highlight_trigger"><title>Changing styles with triggers</title>
<programlisting>
$world->trigger('Joe', { name => 'joe', style => { enabled => 1,
fg => 16 } });
</programlisting>
</example>
<para>These are the valid attributes:</para>
<itemizedlist>
<listitem><para><literal>enabled</literal>: Set this to 1 to enable
changing the style.</para></listitem>
<listitem><para><literal>target</literal>: What to highlight.
Possible values are:</para>
<screen>
-1 - The whole matched line
0 - The whole substring that matched
1 - The first captured substring
2 - The second captured substring
3 - etc.
</screen></listitem>
<listitem><para><literal>fg</literal>: What to do with the
foreground colour. -1 means not to change it. Other values change to
the given color, as follows:</para>
<screen>
0 - black 9 - black (bold)
1 - red 10 - red (bold)
2 - green 11 - green (bold)
3 - yellow 12 - yellow (bold)
4 - blue 13 - blue (bold)
5 - magenta 14 - magenta (bold)
6 - cyan 15 - cyan (bold)
7 - white 16 - white (bold)
8 - the default color 17 - default bold color
</screen></listitem>
<listitem><para><literal>bg</literal>: What to do with the
background color. The values are the same as for the foreground
color.</para></listitem>
<listitem><para><literal>italics</literal>: Italics setting. -1
means do not change. 0 means to not use italics, and 1 means to use
it.</para></listitem>
<listitem><para><literal>strike</literal>: Strike-thru setting. -1
means do not change. 0 means disable it, and 1 means enable
it.</para></listitem>
<listitem><para><literal>underline</literal>: Underline setting. -1
means no change. 0 means no underline. 1 means single underline, and
2 means double underline.</para></listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</sect1>
<sect1 id="func:triggerenabled">
<title id="func:triggerenabled.title">
<function>$world->triggerenabled</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>result = <function>$world->triggerenabled</function></funcdef>
<paramdef>
<parameter>name/number</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>This functions checks whether the specified trigger exists and
whether it is enabled.</para>
<para>You can pass either a trigger number or name. If the trigger
does not exist, this function returns <literal>undef</literal>, so you
can distinguish the case of a non-existant trigger from a disabled
one.</para>
<para>If the trigger exists, then the function returns 0 or 1
depending on whether it is enabled or not. If you pass a name, and
there are several triggers with the same name, it returns a list with
one value for each trigger with that name, and each value is 0 or 1
depending on the state of the trigger.</para>
</sect1>
<sect1 id="func:writetolog">
<title id="func:writetolog.title"><function>$world->writetolog</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>$world->writetolog</function></funcdef>
<paramdef>
<parameter>str</parameter>
</paramdef>
<paramdef>
<parameter>...</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Writes the given line to the log file, if any. If logging is not
currently enabled, then this function does nothing.</para>
<para>Each argument is a complete line, that is written preceded by a
timestamp, if this is enabled, to the log file. If the string has ANSI
codes or codes used by the <xref linkend="func:colorize" endterm="func:colorize.title"/> function, they will be stripped and
not written to the log file.</para>
<para>See also <xref linkend="func:logfile" endterm="func:logfile.title"/>.</para>
</sect1>
</appendix>
<appendix id="app:KCWin"><title>Using KCWin for Input/Output
Windows</title>
<para><literal>KCWin</literal> is a standard plugin distributed with
KildClient that allows you to create windows with a terminal for
output and an entry box for input. These windows do nothing by
themselves, but they can be used by other plugins when they need a
window for input and output. The output area supports ANSI colors and
thus is like a mini MUD window.</para>
<para>This plugin requires the gtk2-perl bindings. It will fail to run
if these bindings are not found.</para>
<para>This plugin is more often used as a helper for other plugins. A
plugin that uses <literal>KCWin</literal> should use
<literal>$::world->requireplugin('KCWin')</literal> in a
<literal>BEGIN</literal> block, as described in <xref linkend="sec:pluginsrequiringothers"/>.</para>
<para>Use <function>KCWin->new</function> to create a new window.
<classname>KCWin</classname> derives from
<classname>Gtk2::Window</classname> so you can use all of its
methods.</para>
<para>The widgets are accessible for customization. If
<varname>$kcw</varname> is a <classname>KCWin</classname>, the
following widgets are available:</para>
<itemizedlist>
<listitem><para><varname>$kcw->{VBOX}</varname>,
<classname>Gtk2::VBox</classname>, the vertical box that contains
the output and input areas.</para></listitem>
<listitem><para><varname>$kcw->{SCROLLWIN}</varname>,
<classname>Gtk2::ScrolledWindow</classname>Gtk2::ScrolledWindow, this
holds the TextView that is used for output.</para></listitem>
<listitem><para><varname>$kcw->{TEXTVIEW}</varname>,
<classname>Gtk2::TextView</classname>, is the widget used for
output.</para></listitem>
<listitem><para><varname>$kcw->{TEXTBUFFER}</varname>,
<classname>Gtk2::TextBuffer</classname>, for convenience, the
TextBuffer displayed in the window.</para></listitem>
<listitem><para><varname>$kcw->{CMDAREA}</varname>,
<classname>Gtk2::HBox</classname>, a box that holds a button to
clear the input area, and the input area itself.</para></listitem>
<listitem><para><varname>$kcw->{BTNCLEAR}</varname>,
<classname>Gtk2::Button</classname>, a button that clears the input
entry widget when clicked.</para></listitem>
<listitem><para><varname>$kcw->{ENTRY}</varname>,
<classname>Gtk2::Entry</classname>, the input entry widget. Connect
to the activate signal of this widget to do something when the user
presses ENTER in this widget.</para></listitem>
</itemizedlist>
<para>The widgets can be used, and the window can be customized (by adding
other widgets, for example). Some common actions have functions in
<classname>KCWin</classname> as a shortcut. These functions will be
described in the following sections.</para>
<sect1><title>Changes from Previous Versions</title>
<para>KCWin version 1.x used a
<classname>Gnome2::Vte::Terminal</classname> for output (the same
widget that was used in the main KildClient window). KCWin version 2.x
(which comes with KildClient 2.x) has changed that in favour of a
<classname>Gtk2::TextView</classname> (to match a change in the main
KildClient program).</para>
<para>If you never used the <varname>KCWin->{VTE}</varname> variable
directly, you will not need to change anything in your plugins that
use KCWin. If you did, you will probably have to change some things.
The new <classname>Gtk2::TextView</classname> widget is accessible via
<varname>KCWin->{TEXTVIEW}</varname>, as described above.</para>
<para>Another feature that has been added is a Clear button just like
in the MUD windows, which clears the entry widget. However, most
plugins should not need to do anything to adapt themselves to
that.</para>
<para>Finally, because of the changes, some more widgets are present
in the window, and accessible via elements of the hash that holds a
<classname>KCWin</classname>. These widgets are responsible for the
layout of the window.</para>
</sect1>
<sect1 id="func:KCwin::get_text">
<title id="func:KCwin::get_text.title"><function>KCWin::get_text</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>$text = <function>KCWin::get_text</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
<para>Returns the text in the entry box.</para>
</sect1>
<sect1 id="func:KCwin::set_text">
<title id="func:KCwin::set_text.title">
<function>KCWin::set_text</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>KCWin::set_text</function></funcdef>
<paramdef>
<parameter>$text</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Sets the text in the entry box.</para>
</sect1>
<sect1 id="func:KCwin::feed">
<title id="func:KCwin::feed.title"><function>KCWin::feed</function></title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>KCWin::feed</function></funcdef>
<paramdef>
<parameter>$text</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>Appends text to the output terminal widget. $text can contain
ANSI color sequences. The <xref linkend="func:colorize" endterm="func:colorize.title"/> function can be useful in conjuntion
with this function.</para>
</sect1>
</appendix>
<appendix><title>Writing Plugins</title>
<para>This appendix will describe how you can write your own plugins
for KildClient. It will describe the format of the plugin file, what
it should have, and some guidelines that all plugins should
follow.</para>
<para>The first thing to decide when writing a plugin is the name.
Since each plugin defines a Perl package, the name should be a valid
name for a Perl package. Moreover, it is a good practice to name the
plugin file with the name of the plugin (although the name of the file
could be different), so stick with letters, numbers, and the
underscore. It should not start with an underscore, however, because
all identifiers that start with an underscore are understood to be
interal of KildClient.</para>
<sect1><title>The File Format</title>
<para>The plugin file is just a Perl file that is read and run by
KildClient when the plugin is loaded. This file can call KildClient's
functions to add triggers, aliases, macros or timers, to set permanent
variables, etc. It usually also defines new subroutines for use in the
triggers, etc, or to be called directly by the user.</para>
<para>However, the plugin file must with a header, which has a fixed
format. If the header is not in this format, the plugin will not be
recognized. The header is shown in <xref linkend="fig:plugin_header"/>.</para>
<figure id="fig:plugin_header"><title>The Plugin Header</title>
<programlisting>
package NAME;
#: Version: VERSION
#: Description: ONE LINE DESCRIPTION
#: Author: AUTHOR'S NAME (OPTIONAL)
</programlisting>
</figure>
<para>The first line defines the plugin's name, which will be used to
refer to it later. It also starts a Perl package. All plugins define a
package, so that one plugin's functions do not interfere with other
plugin's ones.</para>
<para>The second line specifies the plugin's version. This is most
informative, but is also used by KildClient to ensure that only one
version of the plugin is loaded.</para>
<para>Next, there comes a short one-line description of the plugin.
It should be brief but descriptive, and it is shown in the output of
the <function>$world->listplugin</function> function.</para>
<para>Finally, it is possible to inform the author of the plugin. This
line, however, is not required, but the author's name will appear in
the plugin listing if it is informed.</para>
<para>After that, comes the plugin code. This is just Perl code,
executed by KildClient when the plugin is loaded (with
<function>do</function>).</para>
</sect1>
<sect1><title>A Sample Plugin</title>
<para>Here is a simple but complete plugin. It will be used to
illustrate many things about plugins.</para>
<example><title>A Sample Plugin</title>
<programlisting>
package sample;
#: Version: 1.0
#: Description: A Sample Plugin
#: Author: Eduardo M Kalinowski
$::world->trigger('First', 'of the plugin', { name => 'sample:misc' });
$::world->trigger('Second', 'of the plugin', { name => 'sample:misc' });
$::world->timer({ interval => 5, action => 'sample plugin',
name => 'sample:misc' });
$::world->macro('F8', '/sample::stop', { name => 'sample:enadis' });
$::world->macro('F9', '/sample::start', { name => 'sample:enadis' });
sub testplugin {
$::world->echonl("The plugin works.");
}
sub stop {
$::world->distimer('sample:misc');
}
sub start {
$::world->enatimer('sample:misc');
}
sub help {
$::world->echonl("This is a sample plugin, that does nothing useful.");
$::world->echonl("It outputs a short string every now and them. This");
$::world->echonl("behaviour can be stopped by pressing the F8 key, and");
$::world->echonl("re-enabled with the F9 key.");
$::world->echonl("One function is defined: sample::testplugin. It");
$::world->echonl("outputs something to show that the plugin is working.");
}
</programlisting>
</example>
<para>The first thing in the file is the header, in the format
described above. then comes trigger, timer, and macro definitions. All
definitions of triggers, aliases, macros, timers, hook and permanent
variables, if any, should be in the top-level scope (which means they
will be executed when the plugin is loaded). (Alternatively, you could
put them in a <literal>BEGIN</literal> block, which would have the
same result, but there isn't a reason for that.) You should not create
any of those objects in any function.</para>
<para>It should be noted that the <varname>$world</varname> variable
is refereed as <varname>$::world</varname>. It is just because we are
inside a package, and <varname>$world</varname> does not belong to
this package. Otherwise, the calls are equal.</para>
<para>After that, some functions are defined.
<function>testplugin</function> is meant to be called by the user.
<function>stop</function> and <function>start</function> are used by
the macros (but they could also be called by the user). Finally, a
<function>help</function> is defined, that outputs some information
about the plugin. All plugins should define a
<function>help</function> describing themselves.</para>
</sect1>
<sect1><title>Disposing Data When the Plugin Is Unloaded</title>
<para>If the plugin defines a function called
<literal>UNLOAD</literal>, this function will be called when the
plugin is unloaded. Currently this happens only when the World that
loaded the plugin is closed.</para>
<para>If your plugin must dispose of anything it created that would be
kept behind even when the World is closed, the
<literal>UNLOAD</literal> function is the place to do that.</para>
</sect1>
<sect1><title>Enabling and Disabling Plugins</title>
<para>As described in <xref linkend="chap:plugins"/>, the user can
enable or disable plugins. By default, disabling a plugin means
disabling all its triggers, macros, aliases, hooks and timers, and
enabling a plugin means enabling all the above items.</para>
<para>Most of the times that is enough, but for some plugins this
naive approach may not be appropriate. One such case is when a plugin
has some triggers (or any other kind of item) that is not necessarily
always enabled, and whose status is set by some other means.</para>
<para>In these cases, you can define two functions named
<literal>ENABLE</literal> and <literal>DISABLE</literal>. These will
be called when the plugin is being enabled and disabled, respectively,
and you can do whatever is necessary in there.</para>
<para>If these functions are defined, then the standard behaviour
(enabling or disabling all items) is <emphasis>not</emphasis> done,
and you must do whatever is necessary by yourself. Also, no message is
printed, so you might want to print some informative message.</para>
<para>The functions should return a true value to indicate success. If
for some reason the operation could not be done and the status should
not be changed, return a false value and the status of the plugin will
not be altered. But use this feature with care.</para>
<para>If the functions are not defined, then the default behavior
described above is used. So if your plugin doesn't have special needs,
you do not need to define these functions.</para>
</sect1>
<sect1><title>Conditional Loading of Plugins</title>
<para>If your plugin depends on some condition to be successfully
loaded, you should include a test for whatever is required in a
<literal>BEGIN</literal> block, and if the conditions are not present,
you should call the Perl <function>die</function> function passing a
descriptive message telling why the plugin could not be loaded.</para>
<para>For example, here is part of a hypothetical spell-checker plugin
that uses the file <filename>/usr/share/dict/words</filename>
file:</para>
<example><title>Conditional loading of plugins</title>
<programlisting>
package spellcheck;
#: Version: 1.0
#: Description: Spell Checker
#: Author: Somebody
BEGIN {
die("Word file (/usr/share/dict/words) could not be read")
unless -r /usr/share/dict/words;
}
...
</programlisting>
</example>
<para>When the user tries to load that plugin, the test will be made.
If the file cannot be read (because it does not exist, or the
permissiosn are wrong, or for any other reason),
<function>die</function> will be called, the plugin will not be
loaded, and the given message will be printed in the screen.</para>
<sect2 id="sec:pluginsrequiringothers">
<title>Plugins That Require Other Plugins</title>
<para>If your plugin requires some other plugin, you should use the
<function>$world->requireplugin</function> function in a
<literal>BEGIN</literal> block. This function will verify if the named
plugin is already loaded. If it is, it returns successfully. If it is
not loaded, the function will try to load the plugin. If it could be
loaded, the function exits successfully. If, however, the plugin
could not be loaded (because it was not found, or because it failed
some condition), <function>$world->requireplugin</function> will call
<function>die</function>, which will abort the loading the plugin that
required the other plugin.</para>
<para>As an example, consider the plugin foo, which requires the bar
plugin:</para>
<example><title>A plugin that requires another</title>
<programlisting>
package foo;
#: Version: 1.0
#: Description: The Super Frobnicator
#: Author: Somebody
BEGIN {
$::world->requireplugin('bar');
}
...
</programlisting>
</example>
<para>If foo was loaded successfully, you can be sure that the bar
plugin and its functionality is present. If bar could not be loaded,
foo will not be loaded.</para>
</sect2>
</sect1>
<sect1><title>Using GTK+ From Plugins</title>
<para>With the use of the gtk2-perl bindings, it is possible to use
the full power of the GTK+ library in KildClient plugins. This allows
you to create dialogs, windows, message boxes, and anything else your
plugin needs.</para>
<para>Using gtk2-perl in a KildClient plugin is straightforward, there
is just a couple of points to be observed. Import the Perl modules as
usual, generally with a line like this: "<literal>use Gtk2
-init;</literal>". Create windows and display them as usual. The
biggest difference is that you must not call
<literal>Gtk2->main</literal>. Since KildClient is a GTK+ application,
it already runs a main loop, and starting another one would lock
KildClient and make it unresponsive. Also, you must never call
<literal>Gtk2->main_quit</literal>, because that would cause
KildClient to quit. Even tough the world would be saved, the user
certainly wouldn't want that.</para>
<para>All features of GTK+ are supported, as are all of gtk2-modules
(this includes modules for the base libraries Glid and GDK, and also
for other libraries such as the Gnome ones). Notably, Gtk2::GladeXML
is supported, which allows you to create complex user interfaces
visually and load them from the .glade file in the plugin.</para>
<para>Note that having the gtk2-perl bindings is not necessary to run
KildClient. If they are not present, however, it will not be possible
to run plugins that use it, naturally. The plugins will not be loaded
because an error will be generated when the modules are loaded (in the
"<literal>use Gtk2 -init;</literal>" line).</para>
<para>The example below shows a very simple (and not very useful)
plugin using gtk2-perl. It should show how simple it is to use the
gtk2-perl bindings in KildClient plugin.</para>
<example><title>A plugin that uses gtk2-perl</title>
<programlisting>
package gtksample;
#: Version: 1.0.0
#: Description: A Plugin Using gtk2-perl
#: Author: Eduardo M Kalinowski
use Gtk2 -init;
# Is the window being displayed?
our $window_displayed = 0;
# Widgets
our $window;
our $entry;
our $button;
sub help {
$::world->echonl("This plugins demonstrates the use of gtk2-perl under KildClient.",
"It does nothing really useful.",
"",
"Enter /gtksample::run to try it.");
}
sub run {
return if $window_displayed;
$window = Gtk2::Window->new();
$window->set_title("gtk2-perl test");
$window->signal_connect(delete_event => sub {
$window_displayed = 0;
return 0;
});
my $vbox = Gtk2::VBox->new(0, 8);
$entry = Gtk2::Entry->new();
$entry->set_text("Type something here");
$vbox->pack_start($entry, 0, 1, 0);
$button = Gtk2::Button->new("And click me");
$button->signal_connect(clicked => \&on_button_clicked);
$vbox->pack_start($button, 0, 1, 0);
$window->add($vbox);
$window->show_all();
$window_displayed = 1;
}
sub on_button_clicked {
$button->set_label($entry->get_text());
}
sub UNLOAD {
$window->destroy if $window_displayed;
}
</programlisting>
</example>
<para>Notice how it defines a <literal>UNLOAD</literal> function that
destroys the window if it is being displayed. Plugins that open
windows almost always need such a function to delete the windows that
are still open when the World is closed. If these windows are not
closed, the program will most likely crash if the user tries to use
them after the Worlds has been closed, so make sure they get
deleted.</para>
<para>For more information on gtk2-perl, see <ulink url="http://http://gtk2-perl.sourceforge.net/">http://gtk2-perl.sourceforge.net/</ulink>.</para>
</sect1>
<sect1><title>Plugin Conventions</title>
<para>The first convention about plugins has been mentioned already:
all plugins should define a <function>help</function> describing
themselves. This help can be as detailed as necessary.</para>
<para>Another convention regards the use of triggers, aliases, macros,
timers and hooks. All of them should have names (and they should
always be referenced by names, because the plugin writer cannot know
which number will be assigned to them), and the names should consist
of the name of the plugin, a colon, and then some descriptive name for
the trigger (or alias, etc). This is to avoid name clashes with other
plugins.</para>
<para>Another aspect regarding triggers, aliases, macros, timers and
hooks is that they should only be created in the top-level scope,
which means they are created when the plugin is loaded. They must not
be created in a function that is called later, because this way they
would not be recognized as belonging to the plugin, and this would
create a mess for the user. So create them outside any
functions.</para>
</sect1>
</appendix>
</part>
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: xml
sgml-omittag:nil
sgml-shorttag:nil
sgml-namecase-general:nil
sgml-general-insert-case:lower
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:nil
sgml-indent-data:nil
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|