<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://script.quakenet.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cail</id>
	<title>Scriptwiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://script.quakenet.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cail"/>
	<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/Special:Contributions/Cail"/>
	<updated>2026-05-14T13:16:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6243</id>
		<title>Chess game</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6243"/>
		<updated>2024-04-19T13:41:06Z</updated>

		<summary type="html">&lt;p&gt;Cail: DING DONG&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Image:Chess selection.jpg|Screenshot of the gameplay]]&lt;br /&gt;
&lt;br /&gt;
== Source ==&lt;br /&gt;
&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 ; &lt;br /&gt;
 ; Chess game with picture windows by Cail at Quakenet -&amp;gt; #help.script&lt;br /&gt;
 ;&lt;br /&gt;
 ; The singleplayer mode is only for debugging and testing.&lt;br /&gt;
 ; Multiplayer was the main idea, you can use sockets or IRC to play (read help).&lt;br /&gt;
 ; The game will download the pieces automatically and put them into right place,  &lt;br /&gt;
 ; (images originally from mediawiki, by Wapcaplet) and put them into /mircdir/chess directory.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Type /chess to start the game.&lt;br /&gt;
 ; Also support saving and loading the game state.&lt;br /&gt;
 ; Includes logging of moves, shows last move all the time, and last 40/24 moves in a sidepanel, which can be toggled on/off. &lt;br /&gt;
 ;&lt;br /&gt;
 ; Be sure to read the help for full description of all features.&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 &lt;br /&gt;
 alias chess {&lt;br /&gt;
   if ($hget(chess.board))    { hfree chess.board } | hmake chess.board 100&lt;br /&gt;
   if ($hget(chess.info))     { hfree chess.info } | hmake chess.info 100&lt;br /&gt;
   if ($hget(chess.options))  { hfree chess.options } | hmake chess.options 100&lt;br /&gt;
   if ($exists(chess/options.hsh)) { hload chess.options chess/options.hsh }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.options size 100&lt;br /&gt;
     hadd chess.options log_format 1&lt;br /&gt;
     hadd chess.options send_method msg&lt;br /&gt;
     hadd chess.options frames 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50)&lt;br /&gt;
 &lt;br /&gt;
   log_show -200&lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
 &lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,320,140) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,380,200) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,440,260) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,500,320) 300 50&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,330,150) single player (debug)&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,390,210) connect to a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,450,270) start a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,510,330) help &lt;br /&gt;
 &lt;br /&gt;
   if (!$exists($qt($mircdirchess/pieces.png))) { .echo -qg $dialog(chess_getimg,chess_getimg) }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 menu @chess {&lt;br /&gt;
   sclick: chess_sclick&lt;br /&gt;
   dclick: chess_dclick&lt;br /&gt;
   options:.echo -qg $dialog(chess_options,chess_options)&lt;br /&gt;
   help:url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
   $iif($hget(chess.info,init),save):chess_save&lt;br /&gt;
   $iif($hget(chess.info,init),load):chess_load $$dialog(load_table,load_table)&lt;br /&gt;
   $iif($hget(chess.info,mode) == mp,send msg):.echo -qg $dialog(chess_send_pm,chess_send_pm)&lt;br /&gt;
 &lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),-)&lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),save log):log_save&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:close:@chess:{&lt;br /&gt;
   hfree chess.board&lt;br /&gt;
   hfree chess.info&lt;br /&gt;
   hfree chess.options &lt;br /&gt;
 &lt;br /&gt;
   if ($exists(chess/temp.log)) { .remove chess/temp.log }&lt;br /&gt;
   if ($sock(chess_connect)) { sockclose chess_connect }&lt;br /&gt;
   if ($sock(chess)) { sockclose chess }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { chess_send disconnect | .disable #chess.n }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:active:@chess:{ titlebar @chess }&lt;br /&gt;
 &lt;br /&gt;
 dialog load_table {&lt;br /&gt;
   title &amp;quot;Chess&amp;quot;&lt;br /&gt;
   size -1 -1 422 220&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a saved game.&amp;quot;, 1, 7 5 417 20,result&lt;br /&gt;
   list 2, 5 25 410 200, sort&lt;br /&gt;
   button &amp;quot;&amp;quot;, 3, -20 -20 1 1, ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:init:*:{&lt;br /&gt;
   .echo -qg $findfile(chess,*board*.save,0,parse_save $1-)&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_save {&lt;br /&gt;
   .echo -qg $regex($1-,/\\([^\\]+)_board_(.+)\.save/g) &lt;br /&gt;
   var %s = $gettok($regml(1),-1,45)&lt;br /&gt;
   did -a $dname 2 $gettok($regml(1),-4--2,45) $+($mid(%s,1,2),:,$mid(%s,3,2),:,$mid(%s,5,2)) - $regml(2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:dclick:2:{&lt;br /&gt;
   did -ra $dname 1 $did($dname,2).seltext &lt;br /&gt;
   dialog -k $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias chess_restart {&lt;br /&gt;
   hadd chess.info restart 1&lt;br /&gt;
   window -c @chess&lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60)&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
   if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
   hdel chess.info log_shown&lt;br /&gt;
   hdel chess.info log_show&lt;br /&gt;
   log_show -200&lt;br /&gt;
 &lt;br /&gt;
   chess_load&lt;br /&gt;
   hdel chess.info restart&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_load {&lt;br /&gt;
   if (!$hget(chess.info,restart)) {&lt;br /&gt;
     hdel -w chess.board *&lt;br /&gt;
     hdel -w chess.info *&lt;br /&gt;
     hload chess.board $+(chess\,$+($1,-,$remove($2,:)),_board_,$4,.save)&lt;br /&gt;
     hload chess.info $+(chess\,$+($1,-,$remove($2,:)),_info_,$4,.save)&lt;br /&gt;
   }&lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($hget(chess.board,$+(%y,%x))) { draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,restart)) {&lt;br /&gt;
     chess_send load $1 $3&lt;br /&gt;
     if ($hget(chess.info,own_turn)) { print_info light_blue Game loaded succesfully, your turn. }&lt;br /&gt;
     else { print_info light_blue Game loaded succesfully, $hget(chess.info,opponent) $+ &#039;s turn. }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_save {&lt;br /&gt;
   hsave chess.board $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_board_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
   hsave chess.info $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_info_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_initiate {&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
   hadd chess.info clr_select blue&lt;br /&gt;
 &lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($get_piece(%y,%x)) { hadd chess.board $+(%y,%x) $v1 | draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_dclick {&lt;br /&gt;
   if (!$inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520))) { return }&lt;br /&gt;
   var %n = $calc($hget(chess.info,log_lines) - $iif($hget(chess.options,size) == 100,40,24))&lt;br /&gt;
   var %n = $calc($abs(%n) %n)&lt;br /&gt;
 &lt;br /&gt;
   var %log_line = $read(chess/temp.log,$calc($left($calc(($mouse.y *100) /20),-2) + %n))&lt;br /&gt;
   var %clr = $iif($gettok(%log_line,1,32) == white,w,b)&lt;br /&gt;
 &lt;br /&gt;
   if ($gettok(%log_line,2,32) == 0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,1)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,8,4)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,6,2)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,7,3)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($gettok(%log_line,2,32) == 0-0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,4)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,1,8)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,3,5)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,4,6)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) {&lt;br /&gt;
       var %move = $gettok(%log_line,2,32)&lt;br /&gt;
       var %from = $replace($mid(%move,2,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %move = $gettok(%log_line,3,32)&lt;br /&gt;
       var %from = $replace($mid(%move,1,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     var %from.x = $mid(%from,1,1)&lt;br /&gt;
     var %from.y = $mid(%from,2,1)&lt;br /&gt;
     var %to.x = $mid(%to,1,1)&lt;br /&gt;
     var %to.y = $mid(%to,2,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %from.y = $calc(9 - %from.y)&lt;br /&gt;
       var %to.y = $calc(9 - %to.y)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %from.x = $calc(9 - %from.x)&lt;br /&gt;
       var %to.x = $calc(9 - %to.x)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %from.x %from.y light_blue&lt;br /&gt;
     draw_selection %to.x %to.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%from.y,%from.x) $+(%to.y,%to.x)  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_sclick {&lt;br /&gt;
   if ($hget(chess.info,log_select)) { clear_selections $v1 | hdel chess.info log_select }&lt;br /&gt;
 &lt;br /&gt;
   if (!$hget(chess.info,init)) {  &lt;br /&gt;
 &lt;br /&gt;
     ; SELECT: single player&lt;br /&gt;
     if ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,320,140),300,50)) { &lt;br /&gt;
       hadd chess.info init 1 | hadd chess.info clr_own w | hadd chess.info mode sp &lt;br /&gt;
       chess_initiate &lt;br /&gt;
     }   &lt;br /&gt;
     ; SELECT: connect to a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,380,200),300,50)) { &lt;br /&gt;
       connect_dialog&lt;br /&gt;
     }&lt;br /&gt;
     ; SELECT: start a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,440,260),300,50)) { &lt;br /&gt;
       server_dialog&lt;br /&gt;
     } &lt;br /&gt;
     ; SELECT: help&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,500,310),300,50)) { &lt;br /&gt;
       url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
     } &lt;br /&gt;
     return &lt;br /&gt;
   }&lt;br /&gt;
   ; OPEN: log-window&lt;br /&gt;
   elseif ($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,700,380),$iif($hget(chess.options,size) == 100,820,510),125,40)) {&lt;br /&gt;
     if ($hget(chess.info,log_show)) { hdel chess.info log_show | log_show $iif(($hget(chess.options,log_format) == 1),-120,-220) }&lt;br /&gt;
     else { hadd chess.info log_show 1 | log_show $iif(($hget(chess.options,log_format) == 1),+120,+220) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.info,log_shown)) { &lt;br /&gt;
       hadd chess.info log_shown 1&lt;br /&gt;
       if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,own_turn)) { return }&lt;br /&gt;
   if ($hget(chess.info,mode) == sp) { var %clr_own = $iif($hget(chess.info,last_moved) == w,b,w) | hadd chess.info clr_own %clr_own }&lt;br /&gt;
   else { var %clr_own = $hget(chess.info,clr_own) }&lt;br /&gt;
 &lt;br /&gt;
   var %x = $iif($hget(chess.options,size) == 100,$left($calc($mouse.x -20+100),1),$left($calc(((($mouse.x -20) /60) * 100) +100),1))&lt;br /&gt;
   var %y = $iif($hget(chess.options,size) == 100,$left($calc($mouse.y -20+100),1),$left($calc(((($mouse.y -20) /60) * 100) +100),1))&lt;br /&gt;
 &lt;br /&gt;
   var %xy = $+(%y,%x)&lt;br /&gt;
   var %clr_selected = $left($hget(chess.board,%xy),1)&lt;br /&gt;
   var %clr_moved = $hget(chess.info,clr_moved)&lt;br /&gt;
 &lt;br /&gt;
   var %last.x = $hget(chess.info,last.x)&lt;br /&gt;
   var %last.y = $hget(chess.info,last.y)&lt;br /&gt;
   var %last.xy = $+(%last.y,%last.x)&lt;br /&gt;
   var %y-1 = $iif($hget(chess.info,clr_own) == w,$fw(%y,1,%clr_moved),$bw(%y,1,%clr_moved))&lt;br /&gt;
   var %xy-1 = $+(%y-1,%x)&lt;br /&gt;
 &lt;br /&gt;
   var %y2 = $calc(9 - %y)&lt;br /&gt;
   var %x2 = $calc(9 - %x)&lt;br /&gt;
   var %xy2 = $+(%y2,%x2)&lt;br /&gt;
   var %last.x2 = $calc(9 - $hget(chess.info,last.x))&lt;br /&gt;
   var %last.y2 = $calc(9 - $hget(chess.info,last.y))&lt;br /&gt;
   var %last.xy2 = $+(%last.y2,%last.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %is_last = $iif((%x == %last.x) &amp;amp;&amp;amp; (%y == %last.y),$true,$false)&lt;br /&gt;
   var %current_selections = $hget(chess.info,current_selections)&lt;br /&gt;
   var %selected = $hget(chess.info,selected)&lt;br /&gt;
 &lt;br /&gt;
   if (!%selected) &amp;amp;&amp;amp; (%clr_selected != %clr_own) &amp;amp;&amp;amp; ($hget(chess.board,%xy)) { return }&lt;br /&gt;
   elseif (%selected) &amp;amp;&amp;amp; (%clr_selected == %clr_own) {&lt;br /&gt;
     clear_selections %last.xy %current_selections | hdel chess.info selected | hdel chess.info current_selections&lt;br /&gt;
     if (%is_last) { hdel chess.info castling | return } &lt;br /&gt;
     if ($hget(chess.info,castling)) { chess_castling %last.xy %xy $hget(chess.info,clr_own) | return }&lt;br /&gt;
     hdel chess.info castling&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.board,%xy) &amp;amp;&amp;amp; !$hget(chess.info,selected)) { return }&lt;br /&gt;
   elseif (!$istok(%current_selections,%xy,32)) &amp;amp;&amp;amp; (%current_selections) { return }&lt;br /&gt;
 &lt;br /&gt;
   ; a piece is selected, and moveable&lt;br /&gt;
   if ($hget(chess.info,selected)) {&lt;br /&gt;
     hadd chess.info last_moved %clr_own&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,en_passant) == %xy-1) &amp;amp;&amp;amp; ($left($hget(chess.board,%xy-1),1) != %clr_own) { &lt;br /&gt;
       hadd chess.info log_ep 1&lt;br /&gt;
       hdel chess.board %xy-1 &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y-1) 0 $get_square(%x) $get_square(%y-1) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info en_passant&lt;br /&gt;
     hdel chess.info check&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take $v1 }&lt;br /&gt;
     .echo -qg $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     clear_selections %current_selections %last.xy&lt;br /&gt;
     hdel chess.info selected&lt;br /&gt;
     hdel chess.info current_selections&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,king_in_danger)) {&lt;br /&gt;
       if (!$hget(chess.info,just_switched)) { chess_send move %last.xy2 %xy2 }&lt;br /&gt;
       print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
       hdel chess.info own_turn&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info just_switched  &lt;br /&gt;
     hdel chess.info king_in_danger&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; nothing selected, so we&#039;re selecting a piece&lt;br /&gt;
   else {&lt;br /&gt;
     var %piece = $hget(chess.board,%xy)&lt;br /&gt;
     draw_selection %x %y green&lt;br /&gt;
     hadd chess.info selected 1&lt;br /&gt;
     chess_piece_options %piece %x %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info clr_moved %clr_selected&lt;br /&gt;
   hadd chess.info last.x %x&lt;br /&gt;
   hadd chess.info last.y %y&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_piece {&lt;br /&gt;
   var %y = $calc((($replace($left($3,1),w,1,b,3) + $iif($4 == 10407679,0,1)) *100) -100) &lt;br /&gt;
   var %x = $calc($replace($right($3,-2),pawn,0,rook,1,knight,2,bishop,3,queen,4,king,5) *100)&lt;br /&gt;
   drawpic -cms @chess $1 $2 $hget(chess.options,size) $hget(chess.options,size) %x %y 100 100 $qt($mircdirchess/pieces.png)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_selection {&lt;br /&gt;
   if ($3 == red) &amp;amp;&amp;amp; (!$hget(chess.options,frames)) { return }&lt;br /&gt;
   drawrect -r @chess $clr_replace($3) 3 $calc($get_square($1) +1) $calc($get_square($2) +1) $calc($hget(chess.options,size) -2) $calc($hget(chess.options,size) -2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_move {&lt;br /&gt;
   var %piece = $hget(chess.board,$1)&lt;br /&gt;
   var %move_len = $abs($calc($left($3,1) - $left($1,1)))&lt;br /&gt;
 &lt;br /&gt;
   if ($right(%piece,-2) == pawn) {&lt;br /&gt;
     var %l.x = $mid($3,2,1)&lt;br /&gt;
     var %l.y = $mid($3,1,1)&lt;br /&gt;
     var %l.y-1 = $calc(%l.y -1)&lt;br /&gt;
     var %l.xy-1 = $+(%l.y-1,%l.x)&lt;br /&gt;
 &lt;br /&gt;
     if ($istok(1 8,$left($3,1),32)) { &lt;br /&gt;
       var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
       var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
       var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
       var %n.x2 = $calc(9 - $mid($3,2,1))&lt;br /&gt;
       var %n.y2 = $calc(9 - $mid($3,1,1))&lt;br /&gt;
       var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
       .echo -qg $dialog(choose_piece,choose_piece) &lt;br /&gt;
       if ($hget(chess.info,mode) == mp) { chess_send switch %newpiece %n.xy2 %l.xy2 }&lt;br /&gt;
       switch_piece %newpiece $3 $1  &lt;br /&gt;
       hadd chess.info just_switched 1&lt;br /&gt;
 &lt;br /&gt;
       return &lt;br /&gt;
     }&lt;br /&gt;
     elseif (%move_len == 2) { hadd chess.info en_passant $3 }&lt;br /&gt;
  &lt;br /&gt;
     if ($hget(chess.info,opponent_move)) &amp;amp;&amp;amp; ($hget(chess.info,en_passant) == %l.xy-1) {&lt;br /&gt;
        hadd chess.info log_ep 1&lt;br /&gt;
        hdel chess.board %l.xy-1 &lt;br /&gt;
        drawrect -rf @chess $get_color(%l.x,%l.y-1) 0 $get_square(%l.x) $get_square(%l.y-1) $hget(chess.options,size) $hget(chess.options,size) &lt;br /&gt;
     } &lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),_king)) {&lt;br /&gt;
     hadd chess.info $+($1,_king_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 81) {&lt;br /&gt;
     hadd chess.info left_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 88) {&lt;br /&gt;
     hadd chess.info right_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.board $3 %piece&lt;br /&gt;
   hdel chess.board $1&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %piece $mid($3,2,1) $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       hadd chess.info check 1&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) { &lt;br /&gt;
       var %checked 1      &lt;br /&gt;
       chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
     var %n = 1&lt;br /&gt;
     hadd chess.info king_check 1&lt;br /&gt;
     while ($hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_,*),%n,w).data) {&lt;br /&gt;
       var %s = $v1&lt;br /&gt;
       if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
       inc %n&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       hadd chess.info king_in_danger 1&lt;br /&gt;
     }&lt;br /&gt;
     elseif (!$hget(chess.info,just_switched)) &amp;amp;&amp;amp; (!%checked) { chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) } &lt;br /&gt;
 &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,king_in_danger)) {&lt;br /&gt;
     print_info red Illegal move! king would be threated.&lt;br /&gt;
     hadd chess.board $1 %piece&lt;br /&gt;
     if ($hget(chess.info,take)) { hadd chess.board $3 $v1 }&lt;br /&gt;
     else { hdel chess.board $3 }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hdel chess.info just_switched&lt;br /&gt;
     hdel chess.info take&lt;br /&gt;
     hdel chess.info log_ep&lt;br /&gt;
     hdel chess.info opponent_move&lt;br /&gt;
   }&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 &lt;br /&gt;
   return&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l switch_piece {&lt;br /&gt;
   var %x = $mid($2,1,1)&lt;br /&gt;
   var %y = $mid($2,2,1)&lt;br /&gt;
   var %dx = $get_square(%x)&lt;br /&gt;
   var %dy = $get_square(%y)&lt;br /&gt;
   var %piece = $hget(chess.board,$3)&lt;br /&gt;
 &lt;br /&gt;
   var %new_piece = $1&lt;br /&gt;
   hadd chess.board $2 %new_piece&lt;br /&gt;
   hdel chess.board $3&lt;br /&gt;
 &lt;br /&gt;
   draw_piece %dy %dx %new_piece $get_color(%x,%y)  &lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %new_piece %y %x&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
 &lt;br /&gt;
   unset %newpiece&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_castling {&lt;br /&gt;
   var %x.king = $mid($1,2,1)&lt;br /&gt;
   var %y.king = $mid($1,1,1)&lt;br /&gt;
   var %x.rook = $mid($2,2,1)&lt;br /&gt;
   var %y.rook = $mid($2,1,1)&lt;br /&gt;
 &lt;br /&gt;
   var %xy.king = $+(%y.king,%x.king)&lt;br /&gt;
   var %xy.rook = $+(%y.rook,%x.rook)&lt;br /&gt;
   var %king = $+($3,_king)&lt;br /&gt;
   var %rook = $+($3,_rook)&lt;br /&gt;
 &lt;br /&gt;
   var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
   var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
   var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %n.x2 = $calc(9 - $mid($2,2,1))&lt;br /&gt;
   var %n.y2 = $calc(9 - $mid($2,1,1))&lt;br /&gt;
   var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
   if ($3 == $hget(chess.info,clr_own)) {&lt;br /&gt;
     hadd chess.info king_moved 1&lt;br /&gt;
     hadd chess.info $+($iif(%x.rook == 8,right,left),_rook_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if (%x.rook == 8) {&lt;br /&gt;
     var %x+1.king = $calc(%x.king +2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king +1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0,0-0-0)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     var %x+1.king = $calc(%x.king -2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king -1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0-0,0-0)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     ;draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
     ;draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
   draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
 &lt;br /&gt;
   drawrect -rf @chess $get_color(%x.rook,%y.rook) 0 $get_square(%x.rook) $get_square(%y.rook) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
   drawrect -rf @chess $get_color(%x.king,%y.king) 0 $get_square(%x.king) $get_square(%y.king) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.board %xy+1.king %king&lt;br /&gt;
   hadd chess.board %xy-1.king %rook&lt;br /&gt;
   hdel chess.board %xy.rook&lt;br /&gt;
   hdel chess.board %xy.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$4) { &lt;br /&gt;
     chess_send castling %l.xy2 %n.xy2 $3&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
 &lt;br /&gt;
   var %piece = %rook&lt;br /&gt;
   chess_piece_options %piece %x-1.king %y.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check | chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling +&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) %castling +&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) %castling }&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
   hdel chess.info own_turn&lt;br /&gt;
   hdel chess.info castling&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clr_replace {&lt;br /&gt;
   return $replacex($1,red,255,green,65280,blue,16732457,yellow,2751743,light_blue,16749691,white,16777215)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_color {&lt;br /&gt;
   ;return $iif($calc(($1 -($2 % 2)) % 2),0,16777215)&lt;br /&gt;
   return $iif($calc(($1 -($2 % 2)) % 2),4688849,10407679)&lt;br /&gt;
   ; 10407679&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias get_piece {&lt;br /&gt;
   if ($istok(1 2 7 8,$1,32)) { &lt;br /&gt;
     var %c = $hget(chess.info,clr_own)&lt;br /&gt;
     if ($1 == 2) { return $+($iif(%c == w,b,w),_pawn) }&lt;br /&gt;
     elseif ($1 == 7) { return $+(%c,_pawn) }&lt;br /&gt;
     elseif ($1 == 8) { return $+(%c,$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
     else { return $+($iif(%c == w,b,w),$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_square {&lt;br /&gt;
   return $calc((($1 -1) * $hget(chess.options,size)) +20)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clear_selections {&lt;br /&gt;
   var %z = 1 &lt;br /&gt;
   while ($gettok($1-,%z,32)) {&lt;br /&gt;
     var %x = $mid($v1,2,1)&lt;br /&gt;
     var %y = $mid($v1,1,1)&lt;br /&gt;
     var %ispiece = $hget(chess.board,$v1)&lt;br /&gt;
     if ($v1 != 99) { &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 $get_square(%x) $get_square(%y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if (%ispiece) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     }&lt;br /&gt;
     inc %z&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_info {&lt;br /&gt;
   drawrect -rf @chess 3684408 0 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 | drawtext -cro @chess $clr_replace($1) &amp;quot;courier new&amp;quot; $iif($hget(chess.options,size) == 100,16,12) 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l check_square {&lt;br /&gt;
   var %hg = $hget(chess.board,$+($2,$1))&lt;br /&gt;
   var %c = $iif($hget(chess.info,clr_own) == w,b,w)&lt;br /&gt;
   if ($hget(chess.info,king_check)) { var %c = $iif(%c == w,b,w) }&lt;br /&gt;
   if ($3) { var %c = $3 }&lt;br /&gt;
   if (!%hg) || ($left(%hg,1) == %c) { &lt;br /&gt;
     return $true &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l in_board {&lt;br /&gt;
   if ($1 isnum 1-8) &amp;amp;&amp;amp; ($2 isnum 1-8) { return $true }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw+select {&lt;br /&gt;
   if (!$hget(chess.info,king_check)) { draw_selection $1 $2 $hget(chess.info,clr_select) }&lt;br /&gt;
   return $+($2,$1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options_rec {&lt;br /&gt;
   chess_piece_options $1-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l fw { return $calc($1 $iif($3 == w,+,-) $2) }&lt;br /&gt;
 alias -l bw { return $calc($1 $iif($3 == w,-,+) $2) }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options {&lt;br /&gt;
   var %king_check = $hget(chess.info,king_check)&lt;br /&gt;
   var %king_check2 = $hget(chess.info,king_check2) &lt;br /&gt;
 &lt;br /&gt;
   var %piece = $right($1,-2)&lt;br /&gt;
   var %clr_own = $left($1,1)&lt;br /&gt;
 &lt;br /&gt;
   if (!%king_check) {&lt;br /&gt;
     var %clr_own = $iif(%clr_own == w,w,b)&lt;br /&gt;
     var %clr_opponent = $iif(%clr_own == w,b,w)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   var %clr_opponent = $iif(%clr_own == w,b,w) &lt;br /&gt;
 &lt;br /&gt;
   var %x = $2&lt;br /&gt;
   var %y = $3&lt;br /&gt;
 &lt;br /&gt;
   ; PAWN&lt;br /&gt;
   if (%piece == pawn) { &lt;br /&gt;
 &lt;br /&gt;
     var %y+1 = $iif(%clr_own == w,$bw(%y,1,%clr_own),$fw(%y,1,%clr_own))&lt;br /&gt;
     var %y-1 = $iif(%clr_own == w,$fw(%y,1,%clr_own),$bw(%y,1,%clr_own))&lt;br /&gt;
     var %y+2 = $iif(%clr_own == w,$bw(%y,2,%clr_own),$fw(%y,2,%clr_own))&lt;br /&gt;
     var %x+1 = $calc(%x +1)&lt;br /&gt;
     var %x-1 = $calc(%x -1)&lt;br /&gt;
 &lt;br /&gt;
     var %take_left = $+(%y+1,%x+1)&lt;br /&gt;
     var %take_right = $+(%y+1,%x-1)&lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_left),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x+1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x+1)),1) == %clr_opponent))) {    &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x+1,%y+1,%x) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x+1,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_right),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x-1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x-1)),1) == %clr_opponent))) { &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.board,$+(%y+1,%x))) &amp;amp;&amp;amp; (%y+1 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+1 &amp;gt;= 1) &amp;amp;&amp;amp; (!%king_check) {&lt;br /&gt;
       var %select = %select $draw+select(%x,%y+1)&lt;br /&gt;
 &lt;br /&gt;
       ; 2 steps for first move&lt;br /&gt;
       if ($istok(2 7,%y,32)) &amp;amp;&amp;amp; (!$hget(chess.board,$+(%y+2,%x))) &amp;amp;&amp;amp; (%y+2 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+2 &amp;gt; 1) { var %select = %select $draw+select(%x,%y+2) }&lt;br /&gt;
     }&lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; ROOK&lt;br /&gt;
   elseif (%piece == rook) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z } &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; BISHOP&lt;br /&gt;
   elseif (%piece == bishop) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; QUEEN&lt;br /&gt;
   elseif (%piece == queen) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z }    &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KNIGHT&lt;br /&gt;
   elseif (%piece = knight) {&lt;br /&gt;
 &lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %x+2 = $iif(%x == 8,9,$calc(%x +2))&lt;br /&gt;
     var %x-2 = $iif(%x == 1,0,$calc(%x -2))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %y+2 = $iif(%y == 8,9,$calc(%y +2))&lt;br /&gt;
     var %y-2 = $iif(%y == 1,0,$calc(%y -2))&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KING&lt;br /&gt;
   elseif (%piece == king) {&lt;br /&gt;
 &lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %xy = $+(%y,%x)&lt;br /&gt;
 &lt;br /&gt;
     if  (!%king_check) {&lt;br /&gt;
       var %n = 1&lt;br /&gt;
 &lt;br /&gt;
       hadd chess.info king_check 1&lt;br /&gt;
       while ($hfind(chess.board,$+(%clr_opponent,_,*),%n,w).data) {&lt;br /&gt;
         var %s = $v1&lt;br /&gt;
         if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
         inc %n&lt;br /&gt;
       }&lt;br /&gt;
       hdel chess.info king_check&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     if ($check_square(%x+1,%y)) &amp;amp;&amp;amp; ($in_board(%x+1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x+1),32)) { &lt;br /&gt;
       var %select = %select $draw+select(%x+1,%y) &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     if ($check_square(%x-1,%y)) &amp;amp;&amp;amp; ($in_board(%x-1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x-1),32)) { var %select = %select $draw+select(%x-1,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     if ($check_square(%x,%y-1)) &amp;amp;&amp;amp; ($in_board(%x,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x),32)) { var %select = %select $draw+select(%x,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     if ($check_square(%x,%y+1)) &amp;amp;&amp;amp; ($in_board(%x,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x),32)) { var %select = %select $draw+select(%x,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     if ($check_square(%x-1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     if ($check_square(%x-1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     if ($check_square(%x+1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     if ($check_square(%x+1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y+1) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: Castling&lt;br /&gt;
     if (!$hget(chess.info,king_moved)) {&lt;br /&gt;
       var %iy = 8&lt;br /&gt;
       var %lxy = $+(%iy,1)&lt;br /&gt;
       var %rxy = $+(%iy,8)&lt;br /&gt;
 &lt;br /&gt;
       if ($castling_left(%lxy,%iy,%clr_own)) { &lt;br /&gt;
         var %select = %select $draw+select(1,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }&lt;br /&gt;
       if ($castling_right(%rxy,%iy,%clr_own)) {&lt;br /&gt;
         var %select = %select $draw+select(8,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }      &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
 &lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l kc {&lt;br /&gt;
   if ($hget(chess.info,king_check)) {&lt;br /&gt;
     if ($right($hget(chess.board,$+($1,$2)),-2) != king) &amp;amp;&amp;amp; ($hget(chess.board,$+($1,$2))) { return $true }&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($hget(chess.board,$+($1,$2))) {&lt;br /&gt;
     return $true&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_left {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,4))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,4),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_right {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,5),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ;; SOCKETS, msg, notice&lt;br /&gt;
 &lt;br /&gt;
 #chess.n off&lt;br /&gt;
 on ^*:notice:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 on ^*:text:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 #chess.n end&lt;br /&gt;
 &lt;br /&gt;
 alias start_server {&lt;br /&gt;
   if ($hget(chess.info,con_type) != irc) {&lt;br /&gt;
     sockclose chess_connect&lt;br /&gt;
     socklisten chess_connect 6666&lt;br /&gt;
     hadd chess.info init 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.info clr_own w &lt;br /&gt;
   hadd chess.info mode mp &lt;br /&gt;
   hadd chess.info own_turn 1&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 60 $iif($hget(chess.options,size) == 100,560,380) waiting for other player...&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_to_server {&lt;br /&gt;
   sockopen chess %chess.ip %chess.port&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_send { &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { &lt;br /&gt;
     var %m = $iif($hget(chess.options,send_method),$v1,msg)&lt;br /&gt;
     %m $hget(chess.info,opponent) chess_game $1- &lt;br /&gt;
   }&lt;br /&gt;
   else { sockwrite -n chess $1- }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:socklisten:chess_connect:{&lt;br /&gt;
   chess_initiate&lt;br /&gt;
   print_info light_blue You start.&lt;br /&gt;
   sockaccept chess&lt;br /&gt;
   chess_send init $me&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockopen:chess:{ &lt;br /&gt;
   chess_initiate &lt;br /&gt;
   chess_send init $me &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockread:chess:{ &lt;br /&gt;
   var %t&lt;br /&gt;
   sockread %t &lt;br /&gt;
   parse_incoming %t&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockclose:chess:{&lt;br /&gt;
   print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_incoming {&lt;br /&gt;
   if ($active != chess) &amp;amp;&amp;amp; ($1 != cmsg) { flash @chess | titlebar @chess your turn! }&lt;br /&gt;
   tokenize 32 $1-&lt;br /&gt;
 &lt;br /&gt;
   if ($1 == init) { &lt;br /&gt;
     hadd chess.info opponent $2&lt;br /&gt;
     if (!$hget(chess.info,own_turn)) { print_info light_blue $2 starts. }&lt;br /&gt;
     if ($hget(chess.info,con_type) == irc) &amp;amp;&amp;amp; (!$hget(chess.info,init)) {&lt;br /&gt;
       hadd chess.info init 1      &lt;br /&gt;
       chess_initiate&lt;br /&gt;
       print_info light_blue You start.&lt;br /&gt;
       chess_send init $me&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == move) { &lt;br /&gt;
     hadd chess.info own_turn 1 &lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
 &lt;br /&gt;
     var %last.xy = $2&lt;br /&gt;
     var %last.x = $mid(%last.xy,2,1)&lt;br /&gt;
     var %last.y = $mid(%last.xy,1,1) &lt;br /&gt;
 &lt;br /&gt;
     var %xy = $3&lt;br /&gt;
     var %x = $mid(%xy,2,1)&lt;br /&gt;
     var %y = $mid(%xy,1,1)&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take 1 }&lt;br /&gt;
     .echo -gq $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     draw_selection %last.x %last.y light_blue&lt;br /&gt;
     draw_selection %x %y yellow&lt;br /&gt;
     .timerclrlast $+ %xy 1 5 clear_selections %last.xy %xy&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($1 == load) {&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) loaded a game: $2 with $3&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == cmsg) {&lt;br /&gt;
     print_info yellow msg: $2-&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == disconnect) {&lt;br /&gt;
     print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == switch) {&lt;br /&gt;
     hadd chess.info opponent_move 1 &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,$4)) { hadd chess.info take 1 }&lt;br /&gt;
     switch_piece $2-4&lt;br /&gt;
     clear_selections $4&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == castling) { &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
     chess_castling $2-4 1&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; LOGGING&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_show {&lt;br /&gt;
   window -C @chess $window(@chess).x $window(@chess).y $calc($window(@chess).w $1) $window(@chess).h&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_log {&lt;br /&gt;
   if ($2 != 0-0) &amp;amp;&amp;amp; ($2 != 0-0-0) {&lt;br /&gt;
     var %x.from = $mid($2,2,1)&lt;br /&gt;
     var %x.to = $mid($3,2,1)&lt;br /&gt;
     var %y.from = $mid($2,1,1)&lt;br /&gt;
     var %y.to = $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) { &lt;br /&gt;
       var %y.from = $calc(9 - %y.from)&lt;br /&gt;
       var %y.to = $calc(9 - %y.to)&lt;br /&gt;
     }&lt;br /&gt;
     else { &lt;br /&gt;
       var %x.from = $calc(9 - %x.from)&lt;br /&gt;
       var %x.to = $calc(9 - %x.to)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x.from = $gettok(a b c d e f g h,%x.from,32)&lt;br /&gt;
     var %x.to = $gettok(a b c d e f g h,%x.to,32)&lt;br /&gt;
 &lt;br /&gt;
     var %from = $+(%x.from,%y.from)&lt;br /&gt;
     var %to = $+(%x.to,%y.to)&lt;br /&gt;
     var %p = $replace($4,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R)&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) { var %l = $+(%p,%from,$iif((x isin $5) || ($hget(chess.info,log_ep)),x,-),%to,$iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $+ $remove($5,x,s) $iif($hget(chess.info,log_ep),e.p.) }&lt;br /&gt;
     else { var %l = %p $upper(%from) $+ -&amp;gt; $+ $upper(%to) $iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $iif((x isin $5) || ($hget(chess.info,log_ep)),take) $replace($remove($5,x,s),+,check) $iif($hget(chess.info,log_ep),e.p.)  }  &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   else { var %l = $2 $+ $3 }&lt;br /&gt;
   print_last_move light_blue %l&lt;br /&gt;
   print_log $iif($1 == w,white,light_blue) %l&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_last_move {&lt;br /&gt;
   var %z = $width($2-,courier new,16)&lt;br /&gt;
   var %y = $calc($iif($hget(chess.options,size) == 100,820,500) - %z)&lt;br /&gt;
   drawrect -rf @chess 3684408 0 $iif($hget(chess.options,size) == 100,600,280) $iif($hget(chess.options,size) == 100,825,505) 225 20 | drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 %y $iif($hget(chess.options,size) == &lt;br /&gt;
 100,825,505) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_log {&lt;br /&gt;
   write chess\temp.log $1-&lt;br /&gt;
   if (!$hget(chess.info,log_shown)) { return }&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l filter_log {&lt;br /&gt;
   tokenize 32 $1&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
 &lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_save {&lt;br /&gt;
   var %f = $+(chess/,$asctime(yyyy-mm-dd-hhnnss),-,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.log)&lt;br /&gt;
   filter -ff chess\temp.log %f&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; DIALOGS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_dialog { .echo -gq $$dialog(chess_connect,chess_connect) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_connect {&lt;br /&gt;
   title &amp;quot;Create chess connection&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IP&amp;quot;, 1, 7 25 100 20, tab11&lt;br /&gt;
   text &amp;quot;PORT&amp;quot;, 2, 111 25 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 3, 5 42 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 108 42 100 20, tab11&lt;br /&gt;
   button &amp;quot;connect&amp;quot;, 5, 211 41 60 22,default&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC-nick to connect to&amp;quot;, 8, 7 25 150 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 9, 5 42 100 20 , tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:init:*:{&lt;br /&gt;
   did -a $dname 3 %chess.ip&lt;br /&gt;
   did -a $dname 4 $iif(%chess.port,$v1,6666)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:sclick:5:{&lt;br /&gt;
   if ($dialog($dname).tab == 11) {&lt;br /&gt;
     set %chess.ip $did($dname,3)&lt;br /&gt;
     set %chess.port $did($dname,4)&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     connect_to_server&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b | hadd chess.info opponent $did($dname,9)&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     hadd chess.info con_type irc&lt;br /&gt;
     chess_send init $me&lt;br /&gt;
     chess_initiate&lt;br /&gt;
     .enable #chess.n&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_send_pm {&lt;br /&gt;
   title &amp;quot;Send a message&amp;quot;&lt;br /&gt;
   size -1 -1 275 50&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;&amp;quot;, 1, 7 5 250 20,&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 2, 5 25 200 20,&lt;br /&gt;
   button &amp;quot;send&amp;quot; 3, 211 25 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:init:*:{&lt;br /&gt;
   did -a $dname 1 Send a message to $hget(chess.info,opponent)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:sclick:3:{&lt;br /&gt;
   dialog -x chess_send_pm&lt;br /&gt;
   chess_send cmsg $did($dname,2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_getimg {&lt;br /&gt;
   title &amp;quot;Missing files&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;The file pieces.png doesn&#039;t seem to exist in your chess-directory, download it?&amp;quot;, 1, 7 5 270 30,&lt;br /&gt;
   text &amp;quot;&amp;quot;, 2, 7 50 250 20&lt;br /&gt;
   button &amp;quot;download&amp;quot; 3, 211 45 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_getimg:sclick:3:{&lt;br /&gt;
   if (!$hget(chess.info,retry)) { getimg | did -ra $dname 2 downloading... }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt; 5) { getimg }&lt;br /&gt;
   else { dialog -x $dname }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l server_dialog { .echo -gq $$dialog(chess_server,chess_server) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_server {&lt;br /&gt;
   title &amp;quot;Start a chess server&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Start a socket connection&amp;quot;, 1, 7 25 200 20, tab11&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 2, 5 41 60 22,default tab11&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Wait for a connection from nick...&amp;quot;, 3, 7 25 200 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 5 42 100 20 , tab12&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 5, 108 41 60 22,default tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:init:*:{&lt;br /&gt;
   did -a $dname 4 $iif(%chess.nick,$v1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:2:{&lt;br /&gt;
   start_server&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:5:{&lt;br /&gt;
   hadd chess.info con_type irc&lt;br /&gt;
   hadd chess.info opponent $did($dname,4)&lt;br /&gt;
   .enable #chess.n&lt;br /&gt;
   start_server &lt;br /&gt;
   set %chess.nick $did($dname,4)&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog choose_piece {&lt;br /&gt;
   title &amp;quot;Chess - choose new piece&amp;quot;&lt;br /&gt;
   size -1 -1 422 130&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a new piece.&amp;quot;,5, 7 5 417 20&lt;br /&gt;
   button &amp;quot;Queen&amp;quot; 1, 5 25 100 100&lt;br /&gt;
   button &amp;quot;Rook&amp;quot; 2, 108 25 100 100&lt;br /&gt;
   button &amp;quot;Bishop&amp;quot; 3, 211 25 100 100&lt;br /&gt;
   button &amp;quot;Knight&amp;quot; 4, 314 25 100 100&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:choose_piece:sclick:1,2,3,4:{&lt;br /&gt;
   set %newpiece $+($hget(chess.info,clr_own),_,$gettok(queen rook bishop knight,$did,32))&lt;br /&gt;
   dialog -x choose_piece&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_options {&lt;br /&gt;
   title &amp;quot;Chess options&amp;quot;&lt;br /&gt;
   size -1 -1 400 400&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Logging format&amp;quot;, 1, 7 8 100 20&lt;br /&gt;
   combo 2, 110 5 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Square size (pixels)&amp;quot;, 3, 7 30 100 20&lt;br /&gt;
   combo 4, 110 27 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC send method&amp;quot;, 5, 7 52 100 20&lt;br /&gt;
   combo 6, 110 49 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Selection frames&amp;quot;, 7, 7 74 100 20&lt;br /&gt;
   check &amp;quot;&amp;quot; 8, 110 71 20 20,&lt;br /&gt;
 &lt;br /&gt;
   button &amp;quot;save&amp;quot;, 10, 330 370 60 22,ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:init:*:{&lt;br /&gt;
   did -a $dname 2 International (Pe2xf1Q+)&lt;br /&gt;
   did -a $dname 2 New (P E2-&amp;gt;F1 Q take+check)&lt;br /&gt;
   did -c $dname 2 $iif($hget(chess.options,log_format),$v1,1)&lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 4 100&lt;br /&gt;
   did -a $dname 4 60&lt;br /&gt;
   did -c $dname 4 $iif($hget(chess.options,size) == 100,1,2) &lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 6 msg&lt;br /&gt;
   did -a $dname 6 notice&lt;br /&gt;
   did -c $dname 6 $iif($hget(chess.options,send_method) == msg,1,2)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.options,frames)) { did -c $dname 8 }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:sclick:10:{&lt;br /&gt;
   hadd chess.options log_format $did($dname,2).sel&lt;br /&gt;
   if ($did($dname,4).seltext != $hget(chess.options,size)) { hadd chess.options size $did($dname,4).seltext | .timerrestart 1 0 chess_restart }&lt;br /&gt;
   if ($did($dname,8).state == 1) { hadd chess.options frames 1 }&lt;br /&gt;
   else { hdel chess.options frames }&lt;br /&gt;
   hadd chess.options send_method $did($dname,6)&lt;br /&gt;
 &lt;br /&gt;
   hsave chess.options chess/options.hsh&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; FETCH IMAGE&lt;br /&gt;
 alias getimg { &lt;br /&gt;
   if (!$exists(chess)) { mkdir chess }&lt;br /&gt;
   .remove $qt($mircdirchess/pieces.png) &lt;br /&gt;
   sockclose getimg &lt;br /&gt;
   sockopen getimg lost.kapsi.fi 80 &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockopen:getimg:{ &lt;br /&gt;
   sockwrite -nt getimg GET /cail/pieces.png HTTP/1.1 &lt;br /&gt;
   sockwrite -nt getimg Host: lost.kapsi.fi&lt;br /&gt;
   sockwrite -nt getimg Connection: close&lt;br /&gt;
   sockwrite -nt getimg $crlf &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockread:getimg:{ &lt;br /&gt;
   if (!$sock(getimg).mark) { &lt;br /&gt;
     var %t&lt;br /&gt;
     sockread %t&lt;br /&gt;
     if ($gettok(%t,1,32) == Content-Length:) { var %content_len = $gettok(%t,2,32) }&lt;br /&gt;
   }&lt;br /&gt;
   if (!%t) { sockmark getimg $iif(%content_len,$v1,1) }&lt;br /&gt;
   if ($sock(getimg).mark) {&lt;br /&gt;
     sockread -f &amp;amp;img&lt;br /&gt;
     bwrite $qt($mircdirchess/pieces.png) -1 &amp;amp;img&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 on *:sockclose:getimg:{ &lt;br /&gt;
   if ($file($qt($mircdirchess/pieces.png)) == $sock(getimg).mark) || ($sock(getimg).mark == 1) { dialog -x chess_getimg }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt;= 5) { hinc chess.info retry | did chess_getimg 2 Error, trying again... ( $+ $hget(chess.info,retry) $+ ) | .remove $qt($mircdirchess/pieces.png) | getimg }&lt;br /&gt;
   else { did chess_getimg 2 5 retries gone, try again later }&lt;br /&gt;
   unset %content_len&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Help ==&lt;br /&gt;
&lt;br /&gt;
=== The game ===&lt;br /&gt;
&lt;br /&gt;
Singleplayer mode is only for debugging and testing, not actually to play. &lt;br /&gt;
This game is meant to be played as multiplayer, where other player starts a server (whites), &lt;br /&gt;
and other connects to this server (blacks) &lt;br /&gt;
&lt;br /&gt;
=== Server and connecting ===&lt;br /&gt;
&lt;br /&gt;
Two connection types are available, sockets and through IRC with /notice or /msg&lt;br /&gt;
Connection type must be same on both players, the one starting a server must start a server using sockets &lt;br /&gt;
(default), or from server dialog select IRC and input the other players nick (in active server connection)&lt;br /&gt;
&lt;br /&gt;
The connecting player must then select the same connection method from the connect dialog, and input&lt;br /&gt;
the servers IP (sockets) or NICK (IRC),&lt;br /&gt;
note that the same PORT must be used on both clients.&lt;br /&gt;
&lt;br /&gt;
=== Implemented rules === (read more about the rules from wikipedia)&lt;br /&gt;
&lt;br /&gt;
All the pieces move correctly, and you cannot make a move that wouldn&#039;t go by the rules.&lt;br /&gt;
Pawn can perform en passant move, and if advanced to the 8th rank (other side of the board), it gets promoted to queen,rook,bishop,knight of the same color.&lt;br /&gt;
King and rook can perform castling move, if all the requirements are met, selecting king will highlight the rook, if then clicked on the rook, the castling is performed.&lt;br /&gt;
IF king is in check, the game will show the selectiong borders in squares you cannot move, but won&#039;t let you move there if you try.&lt;br /&gt;
&lt;br /&gt;
=== Mouse &amp;amp; menus ===&lt;br /&gt;
&lt;br /&gt;
You select pieces by clicking them, and move them by clicking on the target square, clicking the selected piece will de-select it.&lt;br /&gt;
You&#039;ll find last move from bottom right hand side of the board, clicking it will append the log-window on the right side, where you will see&lt;br /&gt;
40 (with 100px squares) or 24 (60px squares) last moves, doubleclicking a move in the log-window will highlight the move on the board.&lt;br /&gt;
Right clicking anywhere brings you a popup-menu, where you will always find options and help, if in game, also save &amp;amp; load are in this menu.&lt;br /&gt;
If in multiplayer mode, there&#039;s also &amp;quot;send msg&amp;quot;, from where you can send a message to other players infobar (bottom left hand side on the board).&lt;br /&gt;
Right clicking on the log menu let&#039;s you save the log.&lt;br /&gt;
&lt;br /&gt;
=== Saving &amp;amp; loading ===&lt;br /&gt;
&lt;br /&gt;
You can save and load your gamestate, the game will create 2 files into your /chess-folder&lt;br /&gt;
YYYY-MM-DD-HHNNSS_board_OPPONENTSNAME.save and YYYY-MM-DD-HHNNSS_info_OPPONENTSNAME.save&lt;br /&gt;
There will be notification for you, if the opponent loads a game, telling you what game he/she loaded.&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
Logging format: let&#039;s you choose the logging format between &amp;quot;International (Pe2xf1Q+)&amp;quot; and &amp;quot;New (P E2-&amp;gt;F1 Q take+check)&amp;quot;&lt;br /&gt;
Square size: Width &amp;amp; height of the squares in the board in pixels.&lt;br /&gt;
IRC send method: Uses /msg OPPONENT or /notice OPPONENT to send information if connected via IRC.&lt;br /&gt;
Selection frames: Switch on/off showing of the borders in squares where you can move.&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Archive]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6242</id>
		<title>Chess game</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6242"/>
		<updated>2024-04-19T13:40:15Z</updated>

		<summary type="html">&lt;p&gt;Cail: DING DING DING&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Image:Chess selection.jpg|Screenshot of the gameplay]]&lt;br /&gt;
&lt;br /&gt;
== Source ==&lt;br /&gt;
&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 ; &lt;br /&gt;
 ; Chess game with picture windows by Cail at Quakenet -&amp;gt; #help.script&lt;br /&gt;
 ;&lt;br /&gt;
 ; The singleplayer mode is only for debugging and testing.&lt;br /&gt;
 ; Multiplayer was the main idea, you can use sockets or IRC to play (read help).&lt;br /&gt;
 ; The game will download the pieces automatically and put them into right place,  &lt;br /&gt;
 ; (images originally from mediawiki, by Wapcaplet) and put them into /mircdir/chess directory.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Type /chess to start the game.&lt;br /&gt;
 ; Also support saving and loading the game state.&lt;br /&gt;
 ; Includes logging of moves, shows last move all the time, and last 40/24 moves in a sidepanel, which can be toggled on/off.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Be sure to read the help for full description of all features.&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 &lt;br /&gt;
 alias chess {&lt;br /&gt;
   if ($hget(chess.board))    { hfree chess.board } | hmake chess.board 100&lt;br /&gt;
   if ($hget(chess.info))     { hfree chess.info } | hmake chess.info 100&lt;br /&gt;
   if ($hget(chess.options))  { hfree chess.options } | hmake chess.options 100&lt;br /&gt;
   if ($exists(chess/options.hsh)) { hload chess.options chess/options.hsh }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.options size 100&lt;br /&gt;
     hadd chess.options log_format 1&lt;br /&gt;
     hadd chess.options send_method msg&lt;br /&gt;
     hadd chess.options frames 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50)&lt;br /&gt;
 &lt;br /&gt;
   log_show -200&lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
 &lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,320,140) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,380,200) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,440,260) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,500,320) 300 50&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,330,150) single player (debug)&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,390,210) connect to a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,450,270) start a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,510,330) help &lt;br /&gt;
 &lt;br /&gt;
   if (!$exists($qt($mircdirchess/pieces.png))) { .echo -qg $dialog(chess_getimg,chess_getimg) }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 menu @chess {&lt;br /&gt;
   sclick: chess_sclick&lt;br /&gt;
   dclick: chess_dclick&lt;br /&gt;
   options:.echo -qg $dialog(chess_options,chess_options)&lt;br /&gt;
   help:url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
   $iif($hget(chess.info,init),save):chess_save&lt;br /&gt;
   $iif($hget(chess.info,init),load):chess_load $$dialog(load_table,load_table)&lt;br /&gt;
   $iif($hget(chess.info,mode) == mp,send msg):.echo -qg $dialog(chess_send_pm,chess_send_pm)&lt;br /&gt;
 &lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),-)&lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),save log):log_save&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:close:@chess:{&lt;br /&gt;
   hfree chess.board&lt;br /&gt;
   hfree chess.info&lt;br /&gt;
   hfree chess.options &lt;br /&gt;
 &lt;br /&gt;
   if ($exists(chess/temp.log)) { .remove chess/temp.log }&lt;br /&gt;
   if ($sock(chess_connect)) { sockclose chess_connect }&lt;br /&gt;
   if ($sock(chess)) { sockclose chess }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { chess_send disconnect | .disable #chess.n }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:active:@chess:{ titlebar @chess }&lt;br /&gt;
 &lt;br /&gt;
 dialog load_table {&lt;br /&gt;
   title &amp;quot;Chess&amp;quot;&lt;br /&gt;
   size -1 -1 422 220&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a saved game.&amp;quot;, 1, 7 5 417 20,result&lt;br /&gt;
   list 2, 5 25 410 200, sort&lt;br /&gt;
   button &amp;quot;&amp;quot;, 3, -20 -20 1 1, ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:init:*:{&lt;br /&gt;
   .echo -qg $findfile(chess,*board*.save,0,parse_save $1-)&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_save {&lt;br /&gt;
   .echo -qg $regex($1-,/\\([^\\]+)_board_(.+)\.save/g) &lt;br /&gt;
   var %s = $gettok($regml(1),-1,45)&lt;br /&gt;
   did -a $dname 2 $gettok($regml(1),-4--2,45) $+($mid(%s,1,2),:,$mid(%s,3,2),:,$mid(%s,5,2)) - $regml(2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:dclick:2:{&lt;br /&gt;
   did -ra $dname 1 $did($dname,2).seltext &lt;br /&gt;
   dialog -k $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias chess_restart {&lt;br /&gt;
   hadd chess.info restart 1&lt;br /&gt;
   window -c @chess&lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60)&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
   if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
   hdel chess.info log_shown&lt;br /&gt;
   hdel chess.info log_show&lt;br /&gt;
   log_show -200&lt;br /&gt;
 &lt;br /&gt;
   chess_load&lt;br /&gt;
   hdel chess.info restart&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_load {&lt;br /&gt;
   if (!$hget(chess.info,restart)) {&lt;br /&gt;
     hdel -w chess.board *&lt;br /&gt;
     hdel -w chess.info *&lt;br /&gt;
     hload chess.board $+(chess\,$+($1,-,$remove($2,:)),_board_,$4,.save)&lt;br /&gt;
     hload chess.info $+(chess\,$+($1,-,$remove($2,:)),_info_,$4,.save)&lt;br /&gt;
   }&lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($hget(chess.board,$+(%y,%x))) { draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,restart)) {&lt;br /&gt;
     chess_send load $1 $3&lt;br /&gt;
     if ($hget(chess.info,own_turn)) { print_info light_blue Game loaded succesfully, your turn. }&lt;br /&gt;
     else { print_info light_blue Game loaded succesfully, $hget(chess.info,opponent) $+ &#039;s turn. }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_save {&lt;br /&gt;
   hsave chess.board $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_board_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
   hsave chess.info $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_info_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_initiate {&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
   hadd chess.info clr_select blue&lt;br /&gt;
 &lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($get_piece(%y,%x)) { hadd chess.board $+(%y,%x) $v1 | draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_dclick {&lt;br /&gt;
   if (!$inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520))) { return }&lt;br /&gt;
   var %n = $calc($hget(chess.info,log_lines) - $iif($hget(chess.options,size) == 100,40,24))&lt;br /&gt;
   var %n = $calc($abs(%n) %n)&lt;br /&gt;
 &lt;br /&gt;
   var %log_line = $read(chess/temp.log,$calc($left($calc(($mouse.y *100) /20),-2) + %n))&lt;br /&gt;
   var %clr = $iif($gettok(%log_line,1,32) == white,w,b)&lt;br /&gt;
 &lt;br /&gt;
   if ($gettok(%log_line,2,32) == 0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,1)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,8,4)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,6,2)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,7,3)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($gettok(%log_line,2,32) == 0-0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,4)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,1,8)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,3,5)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,4,6)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) {&lt;br /&gt;
       var %move = $gettok(%log_line,2,32)&lt;br /&gt;
       var %from = $replace($mid(%move,2,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %move = $gettok(%log_line,3,32)&lt;br /&gt;
       var %from = $replace($mid(%move,1,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     var %from.x = $mid(%from,1,1)&lt;br /&gt;
     var %from.y = $mid(%from,2,1)&lt;br /&gt;
     var %to.x = $mid(%to,1,1)&lt;br /&gt;
     var %to.y = $mid(%to,2,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %from.y = $calc(9 - %from.y)&lt;br /&gt;
       var %to.y = $calc(9 - %to.y)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %from.x = $calc(9 - %from.x)&lt;br /&gt;
       var %to.x = $calc(9 - %to.x)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %from.x %from.y light_blue&lt;br /&gt;
     draw_selection %to.x %to.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%from.y,%from.x) $+(%to.y,%to.x)  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_sclick {&lt;br /&gt;
   if ($hget(chess.info,log_select)) { clear_selections $v1 | hdel chess.info log_select }&lt;br /&gt;
 &lt;br /&gt;
   if (!$hget(chess.info,init)) {  &lt;br /&gt;
 &lt;br /&gt;
     ; SELECT: single player&lt;br /&gt;
     if ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,320,140),300,50)) { &lt;br /&gt;
       hadd chess.info init 1 | hadd chess.info clr_own w | hadd chess.info mode sp &lt;br /&gt;
       chess_initiate &lt;br /&gt;
     }   &lt;br /&gt;
     ; SELECT: connect to a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,380,200),300,50)) { &lt;br /&gt;
       connect_dialog&lt;br /&gt;
     }&lt;br /&gt;
     ; SELECT: start a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,440,260),300,50)) { &lt;br /&gt;
       server_dialog&lt;br /&gt;
     } &lt;br /&gt;
     ; SELECT: help&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,500,310),300,50)) { &lt;br /&gt;
       url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
     } &lt;br /&gt;
     return &lt;br /&gt;
   }&lt;br /&gt;
   ; OPEN: log-window&lt;br /&gt;
   elseif ($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,700,380),$iif($hget(chess.options,size) == 100,820,510),125,40)) {&lt;br /&gt;
     if ($hget(chess.info,log_show)) { hdel chess.info log_show | log_show $iif(($hget(chess.options,log_format) == 1),-120,-220) }&lt;br /&gt;
     else { hadd chess.info log_show 1 | log_show $iif(($hget(chess.options,log_format) == 1),+120,+220) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.info,log_shown)) { &lt;br /&gt;
       hadd chess.info log_shown 1&lt;br /&gt;
       if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,own_turn)) { return }&lt;br /&gt;
   if ($hget(chess.info,mode) == sp) { var %clr_own = $iif($hget(chess.info,last_moved) == w,b,w) | hadd chess.info clr_own %clr_own }&lt;br /&gt;
   else { var %clr_own = $hget(chess.info,clr_own) }&lt;br /&gt;
 &lt;br /&gt;
   var %x = $iif($hget(chess.options,size) == 100,$left($calc($mouse.x -20+100),1),$left($calc(((($mouse.x -20) /60) * 100) +100),1))&lt;br /&gt;
   var %y = $iif($hget(chess.options,size) == 100,$left($calc($mouse.y -20+100),1),$left($calc(((($mouse.y -20) /60) * 100) +100),1))&lt;br /&gt;
 &lt;br /&gt;
   var %xy = $+(%y,%x)&lt;br /&gt;
   var %clr_selected = $left($hget(chess.board,%xy),1)&lt;br /&gt;
   var %clr_moved = $hget(chess.info,clr_moved)&lt;br /&gt;
 &lt;br /&gt;
   var %last.x = $hget(chess.info,last.x)&lt;br /&gt;
   var %last.y = $hget(chess.info,last.y)&lt;br /&gt;
   var %last.xy = $+(%last.y,%last.x)&lt;br /&gt;
   var %y-1 = $iif($hget(chess.info,clr_own) == w,$fw(%y,1,%clr_moved),$bw(%y,1,%clr_moved))&lt;br /&gt;
   var %xy-1 = $+(%y-1,%x)&lt;br /&gt;
 &lt;br /&gt;
   var %y2 = $calc(9 - %y)&lt;br /&gt;
   var %x2 = $calc(9 - %x)&lt;br /&gt;
   var %xy2 = $+(%y2,%x2)&lt;br /&gt;
   var %last.x2 = $calc(9 - $hget(chess.info,last.x))&lt;br /&gt;
   var %last.y2 = $calc(9 - $hget(chess.info,last.y))&lt;br /&gt;
   var %last.xy2 = $+(%last.y2,%last.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %is_last = $iif((%x == %last.x) &amp;amp;&amp;amp; (%y == %last.y),$true,$false)&lt;br /&gt;
   var %current_selections = $hget(chess.info,current_selections)&lt;br /&gt;
   var %selected = $hget(chess.info,selected)&lt;br /&gt;
 &lt;br /&gt;
   if (!%selected) &amp;amp;&amp;amp; (%clr_selected != %clr_own) &amp;amp;&amp;amp; ($hget(chess.board,%xy)) { return }&lt;br /&gt;
   elseif (%selected) &amp;amp;&amp;amp; (%clr_selected == %clr_own) {&lt;br /&gt;
     clear_selections %last.xy %current_selections | hdel chess.info selected | hdel chess.info current_selections&lt;br /&gt;
     if (%is_last) { hdel chess.info castling | return } &lt;br /&gt;
     if ($hget(chess.info,castling)) { chess_castling %last.xy %xy $hget(chess.info,clr_own) | return }&lt;br /&gt;
     hdel chess.info castling&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.board,%xy) &amp;amp;&amp;amp; !$hget(chess.info,selected)) { return }&lt;br /&gt;
   elseif (!$istok(%current_selections,%xy,32)) &amp;amp;&amp;amp; (%current_selections) { return }&lt;br /&gt;
 &lt;br /&gt;
   ; a piece is selected, and moveable&lt;br /&gt;
   if ($hget(chess.info,selected)) {&lt;br /&gt;
     hadd chess.info last_moved %clr_own&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,en_passant) == %xy-1) &amp;amp;&amp;amp; ($left($hget(chess.board,%xy-1),1) != %clr_own) { &lt;br /&gt;
       hadd chess.info log_ep 1&lt;br /&gt;
       hdel chess.board %xy-1 &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y-1) 0 $get_square(%x) $get_square(%y-1) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info en_passant&lt;br /&gt;
     hdel chess.info check&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take $v1 }&lt;br /&gt;
     .echo -qg $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     clear_selections %current_selections %last.xy&lt;br /&gt;
     hdel chess.info selected&lt;br /&gt;
     hdel chess.info current_selections&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,king_in_danger)) {&lt;br /&gt;
       if (!$hget(chess.info,just_switched)) { chess_send move %last.xy2 %xy2 }&lt;br /&gt;
       print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
       hdel chess.info own_turn&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info just_switched  &lt;br /&gt;
     hdel chess.info king_in_danger&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; nothing selected, so we&#039;re selecting a piece&lt;br /&gt;
   else {&lt;br /&gt;
     var %piece = $hget(chess.board,%xy)&lt;br /&gt;
     draw_selection %x %y green&lt;br /&gt;
     hadd chess.info selected 1&lt;br /&gt;
     chess_piece_options %piece %x %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info clr_moved %clr_selected&lt;br /&gt;
   hadd chess.info last.x %x&lt;br /&gt;
   hadd chess.info last.y %y&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_piece {&lt;br /&gt;
   var %y = $calc((($replace($left($3,1),w,1,b,3) + $iif($4 == 10407679,0,1)) *100) -100) &lt;br /&gt;
   var %x = $calc($replace($right($3,-2),pawn,0,rook,1,knight,2,bishop,3,queen,4,king,5) *100)&lt;br /&gt;
   drawpic -cms @chess $1 $2 $hget(chess.options,size) $hget(chess.options,size) %x %y 100 100 $qt($mircdirchess/pieces.png)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_selection {&lt;br /&gt;
   if ($3 == red) &amp;amp;&amp;amp; (!$hget(chess.options,frames)) { return }&lt;br /&gt;
   drawrect -r @chess $clr_replace($3) 3 $calc($get_square($1) +1) $calc($get_square($2) +1) $calc($hget(chess.options,size) -2) $calc($hget(chess.options,size) -2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_move {&lt;br /&gt;
   var %piece = $hget(chess.board,$1)&lt;br /&gt;
   var %move_len = $abs($calc($left($3,1) - $left($1,1)))&lt;br /&gt;
 &lt;br /&gt;
   if ($right(%piece,-2) == pawn) {&lt;br /&gt;
     var %l.x = $mid($3,2,1)&lt;br /&gt;
     var %l.y = $mid($3,1,1)&lt;br /&gt;
     var %l.y-1 = $calc(%l.y -1)&lt;br /&gt;
     var %l.xy-1 = $+(%l.y-1,%l.x)&lt;br /&gt;
 &lt;br /&gt;
     if ($istok(1 8,$left($3,1),32)) { &lt;br /&gt;
       var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
       var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
       var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
       var %n.x2 = $calc(9 - $mid($3,2,1))&lt;br /&gt;
       var %n.y2 = $calc(9 - $mid($3,1,1))&lt;br /&gt;
       var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
       .echo -qg $dialog(choose_piece,choose_piece) &lt;br /&gt;
       if ($hget(chess.info,mode) == mp) { chess_send switch %newpiece %n.xy2 %l.xy2 }&lt;br /&gt;
       switch_piece %newpiece $3 $1  &lt;br /&gt;
       hadd chess.info just_switched 1&lt;br /&gt;
 &lt;br /&gt;
       return &lt;br /&gt;
     }&lt;br /&gt;
     elseif (%move_len == 2) { hadd chess.info en_passant $3 }&lt;br /&gt;
  &lt;br /&gt;
     if ($hget(chess.info,opponent_move)) &amp;amp;&amp;amp; ($hget(chess.info,en_passant) == %l.xy-1) {&lt;br /&gt;
        hadd chess.info log_ep 1&lt;br /&gt;
        hdel chess.board %l.xy-1 &lt;br /&gt;
        drawrect -rf @chess $get_color(%l.x,%l.y-1) 0 $get_square(%l.x) $get_square(%l.y-1) $hget(chess.options,size) $hget(chess.options,size) &lt;br /&gt;
     } &lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),_king)) {&lt;br /&gt;
     hadd chess.info $+($1,_king_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 81) {&lt;br /&gt;
     hadd chess.info left_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 88) {&lt;br /&gt;
     hadd chess.info right_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.board $3 %piece&lt;br /&gt;
   hdel chess.board $1&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %piece $mid($3,2,1) $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       hadd chess.info check 1&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) { &lt;br /&gt;
       var %checked 1      &lt;br /&gt;
       chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
     var %n = 1&lt;br /&gt;
     hadd chess.info king_check 1&lt;br /&gt;
     while ($hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_,*),%n,w).data) {&lt;br /&gt;
       var %s = $v1&lt;br /&gt;
       if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
       inc %n&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       hadd chess.info king_in_danger 1&lt;br /&gt;
     }&lt;br /&gt;
     elseif (!$hget(chess.info,just_switched)) &amp;amp;&amp;amp; (!%checked) { chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) } &lt;br /&gt;
 &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,king_in_danger)) {&lt;br /&gt;
     print_info red Illegal move! king would be threated.&lt;br /&gt;
     hadd chess.board $1 %piece&lt;br /&gt;
     if ($hget(chess.info,take)) { hadd chess.board $3 $v1 }&lt;br /&gt;
     else { hdel chess.board $3 }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hdel chess.info just_switched&lt;br /&gt;
     hdel chess.info take&lt;br /&gt;
     hdel chess.info log_ep&lt;br /&gt;
     hdel chess.info opponent_move&lt;br /&gt;
   }&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 &lt;br /&gt;
   return&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l switch_piece {&lt;br /&gt;
   var %x = $mid($2,1,1)&lt;br /&gt;
   var %y = $mid($2,2,1)&lt;br /&gt;
   var %dx = $get_square(%x)&lt;br /&gt;
   var %dy = $get_square(%y)&lt;br /&gt;
   var %piece = $hget(chess.board,$3)&lt;br /&gt;
 &lt;br /&gt;
   var %new_piece = $1&lt;br /&gt;
   hadd chess.board $2 %new_piece&lt;br /&gt;
   hdel chess.board $3&lt;br /&gt;
 &lt;br /&gt;
   draw_piece %dy %dx %new_piece $get_color(%x,%y)  &lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %new_piece %y %x&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
 &lt;br /&gt;
   unset %newpiece&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_castling {&lt;br /&gt;
   var %x.king = $mid($1,2,1)&lt;br /&gt;
   var %y.king = $mid($1,1,1)&lt;br /&gt;
   var %x.rook = $mid($2,2,1)&lt;br /&gt;
   var %y.rook = $mid($2,1,1)&lt;br /&gt;
 &lt;br /&gt;
   var %xy.king = $+(%y.king,%x.king)&lt;br /&gt;
   var %xy.rook = $+(%y.rook,%x.rook)&lt;br /&gt;
   var %king = $+($3,_king)&lt;br /&gt;
   var %rook = $+($3,_rook)&lt;br /&gt;
 &lt;br /&gt;
   var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
   var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
   var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %n.x2 = $calc(9 - $mid($2,2,1))&lt;br /&gt;
   var %n.y2 = $calc(9 - $mid($2,1,1))&lt;br /&gt;
   var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
   if ($3 == $hget(chess.info,clr_own)) {&lt;br /&gt;
     hadd chess.info king_moved 1&lt;br /&gt;
     hadd chess.info $+($iif(%x.rook == 8,right,left),_rook_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if (%x.rook == 8) {&lt;br /&gt;
     var %x+1.king = $calc(%x.king +2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king +1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0,0-0-0)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     var %x+1.king = $calc(%x.king -2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king -1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0-0,0-0)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     ;draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
     ;draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
   draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
 &lt;br /&gt;
   drawrect -rf @chess $get_color(%x.rook,%y.rook) 0 $get_square(%x.rook) $get_square(%y.rook) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
   drawrect -rf @chess $get_color(%x.king,%y.king) 0 $get_square(%x.king) $get_square(%y.king) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.board %xy+1.king %king&lt;br /&gt;
   hadd chess.board %xy-1.king %rook&lt;br /&gt;
   hdel chess.board %xy.rook&lt;br /&gt;
   hdel chess.board %xy.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$4) { &lt;br /&gt;
     chess_send castling %l.xy2 %n.xy2 $3&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
 &lt;br /&gt;
   var %piece = %rook&lt;br /&gt;
   chess_piece_options %piece %x-1.king %y.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check | chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling +&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) %castling +&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) %castling }&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
   hdel chess.info own_turn&lt;br /&gt;
   hdel chess.info castling&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clr_replace {&lt;br /&gt;
   return $replacex($1,red,255,green,65280,blue,16732457,yellow,2751743,light_blue,16749691,white,16777215)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_color {&lt;br /&gt;
   ;return $iif($calc(($1 -($2 % 2)) % 2),0,16777215)&lt;br /&gt;
   return $iif($calc(($1 -($2 % 2)) % 2),4688849,10407679)&lt;br /&gt;
   ; 10407679&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias get_piece {&lt;br /&gt;
   if ($istok(1 2 7 8,$1,32)) { &lt;br /&gt;
     var %c = $hget(chess.info,clr_own)&lt;br /&gt;
     if ($1 == 2) { return $+($iif(%c == w,b,w),_pawn) }&lt;br /&gt;
     elseif ($1 == 7) { return $+(%c,_pawn) }&lt;br /&gt;
     elseif ($1 == 8) { return $+(%c,$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
     else { return $+($iif(%c == w,b,w),$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_square {&lt;br /&gt;
   return $calc((($1 -1) * $hget(chess.options,size)) +20)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clear_selections {&lt;br /&gt;
   var %z = 1 &lt;br /&gt;
   while ($gettok($1-,%z,32)) {&lt;br /&gt;
     var %x = $mid($v1,2,1)&lt;br /&gt;
     var %y = $mid($v1,1,1)&lt;br /&gt;
     var %ispiece = $hget(chess.board,$v1)&lt;br /&gt;
     if ($v1 != 99) { &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 $get_square(%x) $get_square(%y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if (%ispiece) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     }&lt;br /&gt;
     inc %z&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_info {&lt;br /&gt;
   drawrect -rf @chess 3684408 0 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 | drawtext -cro @chess $clr_replace($1) &amp;quot;courier new&amp;quot; $iif($hget(chess.options,size) == 100,16,12) 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l check_square {&lt;br /&gt;
   var %hg = $hget(chess.board,$+($2,$1))&lt;br /&gt;
   var %c = $iif($hget(chess.info,clr_own) == w,b,w)&lt;br /&gt;
   if ($hget(chess.info,king_check)) { var %c = $iif(%c == w,b,w) }&lt;br /&gt;
   if ($3) { var %c = $3 }&lt;br /&gt;
   if (!%hg) || ($left(%hg,1) == %c) { &lt;br /&gt;
     return $true &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l in_board {&lt;br /&gt;
   if ($1 isnum 1-8) &amp;amp;&amp;amp; ($2 isnum 1-8) { return $true }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw+select {&lt;br /&gt;
   if (!$hget(chess.info,king_check)) { draw_selection $1 $2 $hget(chess.info,clr_select) }&lt;br /&gt;
   return $+($2,$1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options_rec {&lt;br /&gt;
   chess_piece_options $1-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l fw { return $calc($1 $iif($3 == w,+,-) $2) }&lt;br /&gt;
 alias -l bw { return $calc($1 $iif($3 == w,-,+) $2) }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options {&lt;br /&gt;
   var %king_check = $hget(chess.info,king_check)&lt;br /&gt;
   var %king_check2 = $hget(chess.info,king_check2) &lt;br /&gt;
 &lt;br /&gt;
   var %piece = $right($1,-2)&lt;br /&gt;
   var %clr_own = $left($1,1)&lt;br /&gt;
 &lt;br /&gt;
   if (!%king_check) {&lt;br /&gt;
     var %clr_own = $iif(%clr_own == w,w,b)&lt;br /&gt;
     var %clr_opponent = $iif(%clr_own == w,b,w)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   var %clr_opponent = $iif(%clr_own == w,b,w) &lt;br /&gt;
 &lt;br /&gt;
   var %x = $2&lt;br /&gt;
   var %y = $3&lt;br /&gt;
 &lt;br /&gt;
   ; PAWN&lt;br /&gt;
   if (%piece == pawn) { &lt;br /&gt;
 &lt;br /&gt;
     var %y+1 = $iif(%clr_own == w,$bw(%y,1,%clr_own),$fw(%y,1,%clr_own))&lt;br /&gt;
     var %y-1 = $iif(%clr_own == w,$fw(%y,1,%clr_own),$bw(%y,1,%clr_own))&lt;br /&gt;
     var %y+2 = $iif(%clr_own == w,$bw(%y,2,%clr_own),$fw(%y,2,%clr_own))&lt;br /&gt;
     var %x+1 = $calc(%x +1)&lt;br /&gt;
     var %x-1 = $calc(%x -1)&lt;br /&gt;
 &lt;br /&gt;
     var %take_left = $+(%y+1,%x+1)&lt;br /&gt;
     var %take_right = $+(%y+1,%x-1)&lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_left),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x+1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x+1)),1) == %clr_opponent))) {    &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x+1,%y+1,%x) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x+1,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_right),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x-1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x-1)),1) == %clr_opponent))) { &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.board,$+(%y+1,%x))) &amp;amp;&amp;amp; (%y+1 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+1 &amp;gt;= 1) &amp;amp;&amp;amp; (!%king_check) {&lt;br /&gt;
       var %select = %select $draw+select(%x,%y+1)&lt;br /&gt;
 &lt;br /&gt;
       ; 2 steps for first move&lt;br /&gt;
       if ($istok(2 7,%y,32)) &amp;amp;&amp;amp; (!$hget(chess.board,$+(%y+2,%x))) &amp;amp;&amp;amp; (%y+2 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+2 &amp;gt; 1) { var %select = %select $draw+select(%x,%y+2) }&lt;br /&gt;
     }&lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; ROOK&lt;br /&gt;
   elseif (%piece == rook) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z } &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; BISHOP&lt;br /&gt;
   elseif (%piece == bishop) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; QUEEN&lt;br /&gt;
   elseif (%piece == queen) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z }    &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KNIGHT&lt;br /&gt;
   elseif (%piece = knight) {&lt;br /&gt;
 &lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %x+2 = $iif(%x == 8,9,$calc(%x +2))&lt;br /&gt;
     var %x-2 = $iif(%x == 1,0,$calc(%x -2))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %y+2 = $iif(%y == 8,9,$calc(%y +2))&lt;br /&gt;
     var %y-2 = $iif(%y == 1,0,$calc(%y -2))&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KING&lt;br /&gt;
   elseif (%piece == king) {&lt;br /&gt;
 &lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %xy = $+(%y,%x)&lt;br /&gt;
 &lt;br /&gt;
     if  (!%king_check) {&lt;br /&gt;
       var %n = 1&lt;br /&gt;
 &lt;br /&gt;
       hadd chess.info king_check 1&lt;br /&gt;
       while ($hfind(chess.board,$+(%clr_opponent,_,*),%n,w).data) {&lt;br /&gt;
         var %s = $v1&lt;br /&gt;
         if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
         inc %n&lt;br /&gt;
       }&lt;br /&gt;
       hdel chess.info king_check&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     if ($check_square(%x+1,%y)) &amp;amp;&amp;amp; ($in_board(%x+1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x+1),32)) { &lt;br /&gt;
       var %select = %select $draw+select(%x+1,%y) &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     if ($check_square(%x-1,%y)) &amp;amp;&amp;amp; ($in_board(%x-1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x-1),32)) { var %select = %select $draw+select(%x-1,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     if ($check_square(%x,%y-1)) &amp;amp;&amp;amp; ($in_board(%x,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x),32)) { var %select = %select $draw+select(%x,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     if ($check_square(%x,%y+1)) &amp;amp;&amp;amp; ($in_board(%x,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x),32)) { var %select = %select $draw+select(%x,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     if ($check_square(%x-1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     if ($check_square(%x-1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     if ($check_square(%x+1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     if ($check_square(%x+1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y+1) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: Castling&lt;br /&gt;
     if (!$hget(chess.info,king_moved)) {&lt;br /&gt;
       var %iy = 8&lt;br /&gt;
       var %lxy = $+(%iy,1)&lt;br /&gt;
       var %rxy = $+(%iy,8)&lt;br /&gt;
 &lt;br /&gt;
       if ($castling_left(%lxy,%iy,%clr_own)) { &lt;br /&gt;
         var %select = %select $draw+select(1,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }&lt;br /&gt;
       if ($castling_right(%rxy,%iy,%clr_own)) {&lt;br /&gt;
         var %select = %select $draw+select(8,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }      &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
 &lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l kc {&lt;br /&gt;
   if ($hget(chess.info,king_check)) {&lt;br /&gt;
     if ($right($hget(chess.board,$+($1,$2)),-2) != king) &amp;amp;&amp;amp; ($hget(chess.board,$+($1,$2))) { return $true }&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($hget(chess.board,$+($1,$2))) {&lt;br /&gt;
     return $true&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_left {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,4))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,4),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_right {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,5),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ;; SOCKETS, msg, notice&lt;br /&gt;
 &lt;br /&gt;
 #chess.n off&lt;br /&gt;
 on ^*:notice:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 on ^*:text:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 #chess.n end&lt;br /&gt;
 &lt;br /&gt;
 alias start_server {&lt;br /&gt;
   if ($hget(chess.info,con_type) != irc) {&lt;br /&gt;
     sockclose chess_connect&lt;br /&gt;
     socklisten chess_connect 6666&lt;br /&gt;
     hadd chess.info init 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.info clr_own w &lt;br /&gt;
   hadd chess.info mode mp &lt;br /&gt;
   hadd chess.info own_turn 1&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 60 $iif($hget(chess.options,size) == 100,560,380) waiting for other player...&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_to_server {&lt;br /&gt;
   sockopen chess %chess.ip %chess.port&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_send { &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { &lt;br /&gt;
     var %m = $iif($hget(chess.options,send_method),$v1,msg)&lt;br /&gt;
     %m $hget(chess.info,opponent) chess_game $1- &lt;br /&gt;
   }&lt;br /&gt;
   else { sockwrite -n chess $1- }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:socklisten:chess_connect:{&lt;br /&gt;
   chess_initiate&lt;br /&gt;
   print_info light_blue You start.&lt;br /&gt;
   sockaccept chess&lt;br /&gt;
   chess_send init $me&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockopen:chess:{ &lt;br /&gt;
   chess_initiate &lt;br /&gt;
   chess_send init $me &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockread:chess:{ &lt;br /&gt;
   var %t&lt;br /&gt;
   sockread %t &lt;br /&gt;
   parse_incoming %t&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockclose:chess:{&lt;br /&gt;
   print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_incoming {&lt;br /&gt;
   if ($active != chess) &amp;amp;&amp;amp; ($1 != cmsg) { flash @chess | titlebar @chess your turn! }&lt;br /&gt;
   tokenize 32 $1-&lt;br /&gt;
 &lt;br /&gt;
   if ($1 == init) { &lt;br /&gt;
     hadd chess.info opponent $2&lt;br /&gt;
     if (!$hget(chess.info,own_turn)) { print_info light_blue $2 starts. }&lt;br /&gt;
     if ($hget(chess.info,con_type) == irc) &amp;amp;&amp;amp; (!$hget(chess.info,init)) {&lt;br /&gt;
       hadd chess.info init 1      &lt;br /&gt;
       chess_initiate&lt;br /&gt;
       print_info light_blue You start.&lt;br /&gt;
       chess_send init $me&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == move) { &lt;br /&gt;
     hadd chess.info own_turn 1 &lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
 &lt;br /&gt;
     var %last.xy = $2&lt;br /&gt;
     var %last.x = $mid(%last.xy,2,1)&lt;br /&gt;
     var %last.y = $mid(%last.xy,1,1) &lt;br /&gt;
 &lt;br /&gt;
     var %xy = $3&lt;br /&gt;
     var %x = $mid(%xy,2,1)&lt;br /&gt;
     var %y = $mid(%xy,1,1)&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take 1 }&lt;br /&gt;
     .echo -gq $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     draw_selection %last.x %last.y light_blue&lt;br /&gt;
     draw_selection %x %y yellow&lt;br /&gt;
     .timerclrlast $+ %xy 1 5 clear_selections %last.xy %xy&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($1 == load) {&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) loaded a game: $2 with $3&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == cmsg) {&lt;br /&gt;
     print_info yellow msg: $2-&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == disconnect) {&lt;br /&gt;
     print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == switch) {&lt;br /&gt;
     hadd chess.info opponent_move 1 &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,$4)) { hadd chess.info take 1 }&lt;br /&gt;
     switch_piece $2-4&lt;br /&gt;
     clear_selections $4&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == castling) { &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
     chess_castling $2-4 1&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; LOGGING&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_show {&lt;br /&gt;
   window -C @chess $window(@chess).x $window(@chess).y $calc($window(@chess).w $1) $window(@chess).h&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_log {&lt;br /&gt;
   if ($2 != 0-0) &amp;amp;&amp;amp; ($2 != 0-0-0) {&lt;br /&gt;
     var %x.from = $mid($2,2,1)&lt;br /&gt;
     var %x.to = $mid($3,2,1)&lt;br /&gt;
     var %y.from = $mid($2,1,1)&lt;br /&gt;
     var %y.to = $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) { &lt;br /&gt;
       var %y.from = $calc(9 - %y.from)&lt;br /&gt;
       var %y.to = $calc(9 - %y.to)&lt;br /&gt;
     }&lt;br /&gt;
     else { &lt;br /&gt;
       var %x.from = $calc(9 - %x.from)&lt;br /&gt;
       var %x.to = $calc(9 - %x.to)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x.from = $gettok(a b c d e f g h,%x.from,32)&lt;br /&gt;
     var %x.to = $gettok(a b c d e f g h,%x.to,32)&lt;br /&gt;
 &lt;br /&gt;
     var %from = $+(%x.from,%y.from)&lt;br /&gt;
     var %to = $+(%x.to,%y.to)&lt;br /&gt;
     var %p = $replace($4,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R)&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) { var %l = $+(%p,%from,$iif((x isin $5) || ($hget(chess.info,log_ep)),x,-),%to,$iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $+ $remove($5,x,s) $iif($hget(chess.info,log_ep),e.p.) }&lt;br /&gt;
     else { var %l = %p $upper(%from) $+ -&amp;gt; $+ $upper(%to) $iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $iif((x isin $5) || ($hget(chess.info,log_ep)),take) $replace($remove($5,x,s),+,check) $iif($hget(chess.info,log_ep),e.p.)  }  &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   else { var %l = $2 $+ $3 }&lt;br /&gt;
   print_last_move light_blue %l&lt;br /&gt;
   print_log $iif($1 == w,white,light_blue) %l&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_last_move {&lt;br /&gt;
   var %z = $width($2-,courier new,16)&lt;br /&gt;
   var %y = $calc($iif($hget(chess.options,size) == 100,820,500) - %z)&lt;br /&gt;
   drawrect -rf @chess 3684408 0 $iif($hget(chess.options,size) == 100,600,280) $iif($hget(chess.options,size) == 100,825,505) 225 20 | drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 %y $iif($hget(chess.options,size) == &lt;br /&gt;
 100,825,505) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_log {&lt;br /&gt;
   write chess\temp.log $1-&lt;br /&gt;
   if (!$hget(chess.info,log_shown)) { return }&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l filter_log {&lt;br /&gt;
   tokenize 32 $1&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
 &lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_save {&lt;br /&gt;
   var %f = $+(chess/,$asctime(yyyy-mm-dd-hhnnss),-,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.log)&lt;br /&gt;
   filter -ff chess\temp.log %f&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; DIALOGS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_dialog { .echo -gq $$dialog(chess_connect,chess_connect) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_connect {&lt;br /&gt;
   title &amp;quot;Create chess connection&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IP&amp;quot;, 1, 7 25 100 20, tab11&lt;br /&gt;
   text &amp;quot;PORT&amp;quot;, 2, 111 25 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 3, 5 42 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 108 42 100 20, tab11&lt;br /&gt;
   button &amp;quot;connect&amp;quot;, 5, 211 41 60 22,default&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC-nick to connect to&amp;quot;, 8, 7 25 150 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 9, 5 42 100 20 , tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:init:*:{&lt;br /&gt;
   did -a $dname 3 %chess.ip&lt;br /&gt;
   did -a $dname 4 $iif(%chess.port,$v1,6666)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:sclick:5:{&lt;br /&gt;
   if ($dialog($dname).tab == 11) {&lt;br /&gt;
     set %chess.ip $did($dname,3)&lt;br /&gt;
     set %chess.port $did($dname,4)&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     connect_to_server&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b | hadd chess.info opponent $did($dname,9)&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     hadd chess.info con_type irc&lt;br /&gt;
     chess_send init $me&lt;br /&gt;
     chess_initiate&lt;br /&gt;
     .enable #chess.n&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_send_pm {&lt;br /&gt;
   title &amp;quot;Send a message&amp;quot;&lt;br /&gt;
   size -1 -1 275 50&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;&amp;quot;, 1, 7 5 250 20,&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 2, 5 25 200 20,&lt;br /&gt;
   button &amp;quot;send&amp;quot; 3, 211 25 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:init:*:{&lt;br /&gt;
   did -a $dname 1 Send a message to $hget(chess.info,opponent)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:sclick:3:{&lt;br /&gt;
   dialog -x chess_send_pm&lt;br /&gt;
   chess_send cmsg $did($dname,2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_getimg {&lt;br /&gt;
   title &amp;quot;Missing files&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;The file pieces.png doesn&#039;t seem to exist in your chess-directory, download it?&amp;quot;, 1, 7 5 270 30,&lt;br /&gt;
   text &amp;quot;&amp;quot;, 2, 7 50 250 20&lt;br /&gt;
   button &amp;quot;download&amp;quot; 3, 211 45 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_getimg:sclick:3:{&lt;br /&gt;
   if (!$hget(chess.info,retry)) { getimg | did -ra $dname 2 downloading... }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt; 5) { getimg }&lt;br /&gt;
   else { dialog -x $dname }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l server_dialog { .echo -gq $$dialog(chess_server,chess_server) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_server {&lt;br /&gt;
   title &amp;quot;Start a chess server&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Start a socket connection&amp;quot;, 1, 7 25 200 20, tab11&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 2, 5 41 60 22,default tab11&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Wait for a connection from nick...&amp;quot;, 3, 7 25 200 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 5 42 100 20 , tab12&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 5, 108 41 60 22,default tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:init:*:{&lt;br /&gt;
   did -a $dname 4 $iif(%chess.nick,$v1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:2:{&lt;br /&gt;
   start_server&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:5:{&lt;br /&gt;
   hadd chess.info con_type irc&lt;br /&gt;
   hadd chess.info opponent $did($dname,4)&lt;br /&gt;
   .enable #chess.n&lt;br /&gt;
   start_server &lt;br /&gt;
   set %chess.nick $did($dname,4)&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog choose_piece {&lt;br /&gt;
   title &amp;quot;Chess - choose new piece&amp;quot;&lt;br /&gt;
   size -1 -1 422 130&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a new piece.&amp;quot;,5, 7 5 417 20&lt;br /&gt;
   button &amp;quot;Queen&amp;quot; 1, 5 25 100 100&lt;br /&gt;
   button &amp;quot;Rook&amp;quot; 2, 108 25 100 100&lt;br /&gt;
   button &amp;quot;Bishop&amp;quot; 3, 211 25 100 100&lt;br /&gt;
   button &amp;quot;Knight&amp;quot; 4, 314 25 100 100&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:choose_piece:sclick:1,2,3,4:{&lt;br /&gt;
   set %newpiece $+($hget(chess.info,clr_own),_,$gettok(queen rook bishop knight,$did,32))&lt;br /&gt;
   dialog -x choose_piece&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_options {&lt;br /&gt;
   title &amp;quot;Chess options&amp;quot;&lt;br /&gt;
   size -1 -1 400 400&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Logging format&amp;quot;, 1, 7 8 100 20&lt;br /&gt;
   combo 2, 110 5 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Square size (pixels)&amp;quot;, 3, 7 30 100 20&lt;br /&gt;
   combo 4, 110 27 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC send method&amp;quot;, 5, 7 52 100 20&lt;br /&gt;
   combo 6, 110 49 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Selection frames&amp;quot;, 7, 7 74 100 20&lt;br /&gt;
   check &amp;quot;&amp;quot; 8, 110 71 20 20,&lt;br /&gt;
 &lt;br /&gt;
   button &amp;quot;save&amp;quot;, 10, 330 370 60 22,ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:init:*:{&lt;br /&gt;
   did -a $dname 2 International (Pe2xf1Q+)&lt;br /&gt;
   did -a $dname 2 New (P E2-&amp;gt;F1 Q take+check)&lt;br /&gt;
   did -c $dname 2 $iif($hget(chess.options,log_format),$v1,1)&lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 4 100&lt;br /&gt;
   did -a $dname 4 60&lt;br /&gt;
   did -c $dname 4 $iif($hget(chess.options,size) == 100,1,2) &lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 6 msg&lt;br /&gt;
   did -a $dname 6 notice&lt;br /&gt;
   did -c $dname 6 $iif($hget(chess.options,send_method) == msg,1,2)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.options,frames)) { did -c $dname 8 }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:sclick:10:{&lt;br /&gt;
   hadd chess.options log_format $did($dname,2).sel&lt;br /&gt;
   if ($did($dname,4).seltext != $hget(chess.options,size)) { hadd chess.options size $did($dname,4).seltext | .timerrestart 1 0 chess_restart }&lt;br /&gt;
   if ($did($dname,8).state == 1) { hadd chess.options frames 1 }&lt;br /&gt;
   else { hdel chess.options frames }&lt;br /&gt;
   hadd chess.options send_method $did($dname,6)&lt;br /&gt;
 &lt;br /&gt;
   hsave chess.options chess/options.hsh&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; FETCH IMAGE&lt;br /&gt;
 alias getimg { &lt;br /&gt;
   if (!$exists(chess)) { mkdir chess }&lt;br /&gt;
   .remove $qt($mircdirchess/pieces.png) &lt;br /&gt;
   sockclose getimg &lt;br /&gt;
   sockopen getimg lost.kapsi.fi 80 &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockopen:getimg:{ &lt;br /&gt;
   sockwrite -nt getimg GET /cail/pieces.png HTTP/1.1 &lt;br /&gt;
   sockwrite -nt getimg Host: lost.kapsi.fi&lt;br /&gt;
   sockwrite -nt getimg Connection: close&lt;br /&gt;
   sockwrite -nt getimg $crlf &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockread:getimg:{ &lt;br /&gt;
   if (!$sock(getimg).mark) { &lt;br /&gt;
     var %t&lt;br /&gt;
     sockread %t&lt;br /&gt;
     if ($gettok(%t,1,32) == Content-Length:) { var %content_len = $gettok(%t,2,32) }&lt;br /&gt;
   }&lt;br /&gt;
   if (!%t) { sockmark getimg $iif(%content_len,$v1,1) }&lt;br /&gt;
   if ($sock(getimg).mark) {&lt;br /&gt;
     sockread -f &amp;amp;img&lt;br /&gt;
     bwrite $qt($mircdirchess/pieces.png) -1 &amp;amp;img&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 on *:sockclose:getimg:{ &lt;br /&gt;
   if ($file($qt($mircdirchess/pieces.png)) == $sock(getimg).mark) || ($sock(getimg).mark == 1) { dialog -x chess_getimg }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt;= 5) { hinc chess.info retry | did chess_getimg 2 Error, trying again... ( $+ $hget(chess.info,retry) $+ ) | .remove $qt($mircdirchess/pieces.png) | getimg }&lt;br /&gt;
   else { did chess_getimg 2 5 retries gone, try again later }&lt;br /&gt;
   unset %content_len&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Help ==&lt;br /&gt;
&lt;br /&gt;
=== The game ===&lt;br /&gt;
&lt;br /&gt;
Singleplayer mode is only for debugging and testing, not actually to play. &lt;br /&gt;
This game is meant to be played as multiplayer, where other player starts a server (whites), &lt;br /&gt;
and other connects to this server (blacks) &lt;br /&gt;
&lt;br /&gt;
=== Server and connecting ===&lt;br /&gt;
&lt;br /&gt;
Two connection types are available, sockets and through IRC with /notice or /msg&lt;br /&gt;
Connection type must be same on both players, the one starting a server must start a server using sockets &lt;br /&gt;
(default), or from server dialog select IRC and input the other players nick (in active server connection)&lt;br /&gt;
&lt;br /&gt;
The connecting player must then select the same connection method from the connect dialog, and input&lt;br /&gt;
the servers IP (sockets) or NICK (IRC),&lt;br /&gt;
note that the same PORT must be used on both clients.&lt;br /&gt;
&lt;br /&gt;
=== Implemented rules === (read more about the rules from wikipedia)&lt;br /&gt;
&lt;br /&gt;
All the pieces move correctly, and you cannot make a move that wouldn&#039;t go by the rules.&lt;br /&gt;
Pawn can perform en passant move, and if advanced to the 8th rank (other side of the board), it gets promoted to queen,rook,bishop,knight of the same color.&lt;br /&gt;
King and rook can perform castling move, if all the requirements are met, selecting king will highlight the rook, if then clicked on the rook, the castling is performed.&lt;br /&gt;
IF king is in check, the game will show the selectiong borders in squares you cannot move, but won&#039;t let you move there if you try.&lt;br /&gt;
&lt;br /&gt;
=== Mouse &amp;amp; menus ===&lt;br /&gt;
&lt;br /&gt;
You select pieces by clicking them, and move them by clicking on the target square, clicking the selected piece will de-select it.&lt;br /&gt;
You&#039;ll find last move from bottom right hand side of the board, clicking it will append the log-window on the right side, where you will see&lt;br /&gt;
40 (with 100px squares) or 24 (60px squares) last moves, doubleclicking a move in the log-window will highlight the move on the board.&lt;br /&gt;
Right clicking anywhere brings you a popup-menu, where you will always find options and help, if in game, also save &amp;amp; load are in this menu.&lt;br /&gt;
If in multiplayer mode, there&#039;s also &amp;quot;send msg&amp;quot;, from where you can send a message to other players infobar (bottom left hand side on the board).&lt;br /&gt;
Right clicking on the log menu let&#039;s you save the log.&lt;br /&gt;
&lt;br /&gt;
=== Saving &amp;amp; loading ===&lt;br /&gt;
&lt;br /&gt;
You can save and load your gamestate, the game will create 2 files into your /chess-folder&lt;br /&gt;
YYYY-MM-DD-HHNNSS_board_OPPONENTSNAME.save and YYYY-MM-DD-HHNNSS_info_OPPONENTSNAME.save&lt;br /&gt;
There will be notification for you, if the opponent loads a game, telling you what game he/she loaded.&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
Logging format: let&#039;s you choose the logging format between &amp;quot;International (Pe2xf1Q+)&amp;quot; and &amp;quot;New (P E2-&amp;gt;F1 Q take+check)&amp;quot;&lt;br /&gt;
Square size: Width &amp;amp; height of the squares in the board in pixels.&lt;br /&gt;
IRC send method: Uses /msg OPPONENT or /notice OPPONENT to send information if connected via IRC.&lt;br /&gt;
Selection frames: Switch on/off showing of the borders in squares where you can move.&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Archive]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6241</id>
		<title>Chess game</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Chess_game&amp;diff=6241"/>
		<updated>2020-02-11T21:34:14Z</updated>

		<summary type="html">&lt;p&gt;Cail: Moved source to wiki for no reason, or for reservation, even if slightly defunct.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Image:Chess selection.jpg|Screenshot of the gameplay]]&lt;br /&gt;
&lt;br /&gt;
== Source ==&lt;br /&gt;
&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 ; &lt;br /&gt;
 ; Chess game with picture windows by Cail at Quakenet -&amp;gt; #help.script&lt;br /&gt;
 ;&lt;br /&gt;
 ; The singleplayer mode is only for debugging and testing.&lt;br /&gt;
 ; Multiplayer was the main idea, you can use sockets or IRC to play (read help).&lt;br /&gt;
 ; The game will download the pieces automatically and put them into right place, &lt;br /&gt;
 ; If you are experiencing problems with the game&#039;s download, get the image from: http://lost.kapsi.fi/cail/pieces.png &lt;br /&gt;
 ; (images originally from mediawiki, by Wapcaplet) and put them into /mircdir/chess directory.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Type /chess to start the game.&lt;br /&gt;
 ; Also support saving and loading the game state.&lt;br /&gt;
 ; Includes logging of moves, shows last move all the time, and last 40/24 moves in a sidepanel, which can be toggled on/off.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Be sure to read the help for full description of all features.&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; &lt;br /&gt;
 &lt;br /&gt;
 alias chess {&lt;br /&gt;
   if ($hget(chess.board))    { hfree chess.board } | hmake chess.board 100&lt;br /&gt;
   if ($hget(chess.info))     { hfree chess.info } | hmake chess.info 100&lt;br /&gt;
   if ($hget(chess.options))  { hfree chess.options } | hmake chess.options 100&lt;br /&gt;
   if ($exists(chess/options.hsh)) { hload chess.options chess/options.hsh }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.options size 100&lt;br /&gt;
     hadd chess.options log_format 1&lt;br /&gt;
     hadd chess.options send_method msg&lt;br /&gt;
     hadd chess.options frames 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +50)&lt;br /&gt;
 &lt;br /&gt;
   log_show -200&lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
 &lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,320,140) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,380,200) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,440,260) 300 50&lt;br /&gt;
   drawrect -r @chess 65280 1 60 $iif($hget(chess.options,size) == 100,500,320) 300 50&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,330,150) single player (debug)&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,390,210) connect to a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,450,270) start a server&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 70 $iif($hget(chess.options,size) == 100,510,330) help &lt;br /&gt;
 &lt;br /&gt;
   if (!$exists($qt($mircdirchess/pieces.png))) { .echo -qg $dialog(chess_getimg,chess_getimg) }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 menu @chess {&lt;br /&gt;
   sclick: chess_sclick&lt;br /&gt;
   dclick: chess_dclick&lt;br /&gt;
   options:.echo -qg $dialog(chess_options,chess_options)&lt;br /&gt;
   help:url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
   $iif($hget(chess.info,init),save):chess_save&lt;br /&gt;
   $iif($hget(chess.info,init),load):chess_load $$dialog(load_table,load_table)&lt;br /&gt;
   $iif($hget(chess.info,mode) == mp,send msg):.echo -qg $dialog(chess_send_pm,chess_send_pm)&lt;br /&gt;
 &lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),-)&lt;br /&gt;
   $iif($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520)),save log):log_save&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:close:@chess:{&lt;br /&gt;
   hfree chess.board&lt;br /&gt;
   hfree chess.info&lt;br /&gt;
   hfree chess.options &lt;br /&gt;
 &lt;br /&gt;
   if ($exists(chess/temp.log)) { .remove chess/temp.log }&lt;br /&gt;
   if ($sock(chess_connect)) { sockclose chess_connect }&lt;br /&gt;
   if ($sock(chess)) { sockclose chess }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { chess_send disconnect | .disable #chess.n }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:active:@chess:{ titlebar @chess }&lt;br /&gt;
 &lt;br /&gt;
 dialog load_table {&lt;br /&gt;
   title &amp;quot;Chess&amp;quot;&lt;br /&gt;
   size -1 -1 422 220&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a saved game.&amp;quot;, 1, 7 5 417 20,result&lt;br /&gt;
   list 2, 5 25 410 200, sort&lt;br /&gt;
   button &amp;quot;&amp;quot;, 3, -20 -20 1 1, ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:init:*:{&lt;br /&gt;
   .echo -qg $findfile(chess,*board*.save,0,parse_save $1-)&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_save {&lt;br /&gt;
   .echo -qg $regex($1-,/\\([^\\]+)_board_(.+)\.save/g) &lt;br /&gt;
   var %s = $gettok($regml(1),-1,45)&lt;br /&gt;
   did -a $dname 2 $gettok($regml(1),-4--2,45) $+($mid(%s,1,2),:,$mid(%s,3,2),:,$mid(%s,5,2)) - $regml(2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:load_table:dclick:2:{&lt;br /&gt;
   did -ra $dname 1 $did($dname,2).seltext &lt;br /&gt;
   dialog -k $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias chess_restart {&lt;br /&gt;
   hadd chess.info restart 1&lt;br /&gt;
   window -c @chess&lt;br /&gt;
   window -adfpw0C +nft @chess 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60) &lt;br /&gt;
   drawrect -rf @chess 3684408 0 0 0 $calc(($hget(chess.options,size) *8) +240) $calc(($hget(chess.options,size) *8) +60)&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info log_lines 0&lt;br /&gt;
   if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
   hdel chess.info log_shown&lt;br /&gt;
   hdel chess.info log_show&lt;br /&gt;
   log_show -200&lt;br /&gt;
 &lt;br /&gt;
   chess_load&lt;br /&gt;
   hdel chess.info restart&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_load {&lt;br /&gt;
   if (!$hget(chess.info,restart)) {&lt;br /&gt;
     hdel -w chess.board *&lt;br /&gt;
     hdel -w chess.info *&lt;br /&gt;
     hload chess.board $+(chess\,$+($1,-,$remove($2,:)),_board_,$4,.save)&lt;br /&gt;
     hload chess.info $+(chess\,$+($1,-,$remove($2,:)),_info_,$4,.save)&lt;br /&gt;
   }&lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($hget(chess.board,$+(%y,%x))) { draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,restart)) {&lt;br /&gt;
     chess_send load $1 $3&lt;br /&gt;
     if ($hget(chess.info,own_turn)) { print_info light_blue Game loaded succesfully, your turn. }&lt;br /&gt;
     else { print_info light_blue Game loaded succesfully, $hget(chess.info,opponent) $+ &#039;s turn. }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_save {&lt;br /&gt;
   hsave chess.board $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_board_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
   hsave chess.info $+(chess/,$asctime(yyyy-mm-dd-hhnnss),_info_,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.save)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_initiate {&lt;br /&gt;
   drawrect -r @chess 22456 3 17 17 $iif($hget(chess.options,size) == 100,806,486) $iif($hget(chess.options,size) == 100,806,486)&lt;br /&gt;
   hadd chess.info clr_select blue&lt;br /&gt;
 &lt;br /&gt;
   var %y = 1&lt;br /&gt;
   while (%y &amp;lt;= 8) {&lt;br /&gt;
     var %x = 1&lt;br /&gt;
     while (%x &amp;lt;= 8) {&lt;br /&gt;
       var %dx = $get_square(%x)&lt;br /&gt;
       var %dy = $get_square(%y)&lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 %dx %dy $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if ($get_piece(%y,%x)) { hadd chess.board $+(%y,%x) $v1 | draw_piece %dx %dy $v1 $get_color(%x,%y) }&lt;br /&gt;
 &lt;br /&gt;
       var %alph = $gettok(A B C D E F G H I J K L M,$iif($hget(chess.info,clr_own) == w,%x,$calc(9 - %x)),32)&lt;br /&gt;
       var %xz = $calc((($hget(chess.options,size) * %x) + ($hget(chess.options,size)/2+15)) - $hget(chess.options,size))&lt;br /&gt;
       drawtext -ro @chess 16749691 verdana 16 %xz 0 %alph&lt;br /&gt;
 &lt;br /&gt;
       inc %x&lt;br /&gt;
     }  &lt;br /&gt;
 &lt;br /&gt;
     var %yz = $calc((($hget(chess.options,size) * %y) + ($hget(chess.options,size)/2+10)) - $hget(chess.options,size))&lt;br /&gt;
     drawtext -ro @chess 16749691 verdana 16 5 %yz $iif($hget(chess.info,clr_own) == w,$calc(9 - %y),%y)&lt;br /&gt;
 &lt;br /&gt;
     inc %y  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_dclick {&lt;br /&gt;
   if (!$inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,840,520),20,200,$iif($hget(chess.options,size) == 100,840,520))) { return }&lt;br /&gt;
   var %n = $calc($hget(chess.info,log_lines) - $iif($hget(chess.options,size) == 100,40,24))&lt;br /&gt;
   var %n = $calc($abs(%n) %n)&lt;br /&gt;
 &lt;br /&gt;
   var %log_line = $read(chess/temp.log,$calc($left($calc(($mouse.y *100) /20),-2) + %n))&lt;br /&gt;
   var %clr = $iif($gettok(%log_line,1,32) == white,w,b)&lt;br /&gt;
 &lt;br /&gt;
   if ($gettok(%log_line,2,32) == 0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,1)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,8,4)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,6,2)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,7,3)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($gettok(%log_line,2,32) == 0-0-0) {&lt;br /&gt;
     var %f.y = $iif($gettok(%log_line,1,32) == light_blue,8,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %f.y = $calc(9 - %f.y)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x1 = $iif($hget(chess.info,clr_own) == w,5,4)&lt;br /&gt;
     var %x2 = $iif($hget(chess.info,clr_own) == w,1,8)&lt;br /&gt;
     var %x3 = $iif($hget(chess.info,clr_own) == w,3,5)&lt;br /&gt;
     var %x4 = $iif($hget(chess.info,clr_own) == w,4,6)&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %x1 %f.y light_blue&lt;br /&gt;
     draw_selection %x2 %f.y light_blue&lt;br /&gt;
     draw_selection %x3 %f.y yellow&lt;br /&gt;
     draw_selection %x4 %f.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%f.y,%x1) $+(%f.y,%x2) $+(%f.y,%x3) $+(%f.y,%x4)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) {&lt;br /&gt;
       var %move = $gettok(%log_line,2,32)&lt;br /&gt;
       var %from = $replace($mid(%move,2,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %move = $gettok(%log_line,3,32)&lt;br /&gt;
       var %from = $replace($mid(%move,1,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
       var %to = $replace($mid(%move,5,2),a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8)&lt;br /&gt;
     }&lt;br /&gt;
     var %from.x = $mid(%from,1,1)&lt;br /&gt;
     var %from.y = $mid(%from,2,1)&lt;br /&gt;
     var %to.x = $mid(%to,1,1)&lt;br /&gt;
     var %to.y = $mid(%to,2,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
       var %from.y = $calc(9 - %from.y)&lt;br /&gt;
       var %to.y = $calc(9 - %to.y)&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
       var %from.x = $calc(9 - %from.x)&lt;br /&gt;
       var %to.x = $calc(9 - %to.x)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     draw_selection %from.x %from.y light_blue&lt;br /&gt;
     draw_selection %to.x %to.y yellow&lt;br /&gt;
     hadd chess.info log_select $+(%from.y,%from.x) $+(%to.y,%to.x)  &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_sclick {&lt;br /&gt;
   if ($hget(chess.info,log_select)) { clear_selections $v1 | hdel chess.info log_select }&lt;br /&gt;
 &lt;br /&gt;
   if (!$hget(chess.info,init)) {  &lt;br /&gt;
 &lt;br /&gt;
     ; SELECT: single player&lt;br /&gt;
     if ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,320,140),300,50)) { &lt;br /&gt;
       hadd chess.info init 1 | hadd chess.info clr_own w | hadd chess.info mode sp &lt;br /&gt;
       chess_initiate &lt;br /&gt;
     }   &lt;br /&gt;
     ; SELECT: connect to a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,380,200),300,50)) { &lt;br /&gt;
       connect_dialog&lt;br /&gt;
     }&lt;br /&gt;
     ; SELECT: start a server&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,440,260),300,50)) { &lt;br /&gt;
       server_dialog&lt;br /&gt;
     } &lt;br /&gt;
     ; SELECT: help&lt;br /&gt;
     elseif ($inrect($mouse.x,$mouse.y,60,$iif($hget(chess.options,size) == 100,500,310),300,50)) { &lt;br /&gt;
       url -n http://wiki.prco23.org/index.php/Chess_game#Help&lt;br /&gt;
     } &lt;br /&gt;
     return &lt;br /&gt;
   }&lt;br /&gt;
   ; OPEN: log-window&lt;br /&gt;
   elseif ($inrect($mouse.x,$mouse.y,$iif($hget(chess.options,size) == 100,700,380),$iif($hget(chess.options,size) == 100,820,510),125,40)) {&lt;br /&gt;
     if ($hget(chess.info,log_show)) { hdel chess.info log_show | log_show $iif(($hget(chess.options,log_format) == 1),-120,-220) }&lt;br /&gt;
     else { hadd chess.info log_show 1 | log_show $iif(($hget(chess.options,log_format) == 1),+120,+220) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.info,log_shown)) { &lt;br /&gt;
       hadd chess.info log_shown 1&lt;br /&gt;
       if ($exists(chess/temp.log)) { filter -fk chess/temp.log filter_log * }&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,own_turn)) { return }&lt;br /&gt;
   if ($hget(chess.info,mode) == sp) { var %clr_own = $iif($hget(chess.info,last_moved) == w,b,w) | hadd chess.info clr_own %clr_own }&lt;br /&gt;
   else { var %clr_own = $hget(chess.info,clr_own) }&lt;br /&gt;
 &lt;br /&gt;
   var %x = $iif($hget(chess.options,size) == 100,$left($calc($mouse.x -20+100),1),$left($calc(((($mouse.x -20) /60) * 100) +100),1))&lt;br /&gt;
   var %y = $iif($hget(chess.options,size) == 100,$left($calc($mouse.y -20+100),1),$left($calc(((($mouse.y -20) /60) * 100) +100),1))&lt;br /&gt;
 &lt;br /&gt;
   var %xy = $+(%y,%x)&lt;br /&gt;
   var %clr_selected = $left($hget(chess.board,%xy),1)&lt;br /&gt;
   var %clr_moved = $hget(chess.info,clr_moved)&lt;br /&gt;
 &lt;br /&gt;
   var %last.x = $hget(chess.info,last.x)&lt;br /&gt;
   var %last.y = $hget(chess.info,last.y)&lt;br /&gt;
   var %last.xy = $+(%last.y,%last.x)&lt;br /&gt;
   var %y-1 = $iif($hget(chess.info,clr_own) == w,$fw(%y,1,%clr_moved),$bw(%y,1,%clr_moved))&lt;br /&gt;
   var %xy-1 = $+(%y-1,%x)&lt;br /&gt;
 &lt;br /&gt;
   var %y2 = $calc(9 - %y)&lt;br /&gt;
   var %x2 = $calc(9 - %x)&lt;br /&gt;
   var %xy2 = $+(%y2,%x2)&lt;br /&gt;
   var %last.x2 = $calc(9 - $hget(chess.info,last.x))&lt;br /&gt;
   var %last.y2 = $calc(9 - $hget(chess.info,last.y))&lt;br /&gt;
   var %last.xy2 = $+(%last.y2,%last.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %is_last = $iif((%x == %last.x) &amp;amp;&amp;amp; (%y == %last.y),$true,$false)&lt;br /&gt;
   var %current_selections = $hget(chess.info,current_selections)&lt;br /&gt;
   var %selected = $hget(chess.info,selected)&lt;br /&gt;
 &lt;br /&gt;
   if (!%selected) &amp;amp;&amp;amp; (%clr_selected != %clr_own) &amp;amp;&amp;amp; ($hget(chess.board,%xy)) { return }&lt;br /&gt;
   elseif (%selected) &amp;amp;&amp;amp; (%clr_selected == %clr_own) {&lt;br /&gt;
     clear_selections %last.xy %current_selections | hdel chess.info selected | hdel chess.info current_selections&lt;br /&gt;
     if (%is_last) { hdel chess.info castling | return } &lt;br /&gt;
     if ($hget(chess.info,castling)) { chess_castling %last.xy %xy $hget(chess.info,clr_own) | return }&lt;br /&gt;
     hdel chess.info castling&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.board,%xy) &amp;amp;&amp;amp; !$hget(chess.info,selected)) { return }&lt;br /&gt;
   elseif (!$istok(%current_selections,%xy,32)) &amp;amp;&amp;amp; (%current_selections) { return }&lt;br /&gt;
 &lt;br /&gt;
   ; a piece is selected, and moveable&lt;br /&gt;
   if ($hget(chess.info,selected)) {&lt;br /&gt;
     hadd chess.info last_moved %clr_own&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,en_passant) == %xy-1) &amp;amp;&amp;amp; ($left($hget(chess.board,%xy-1),1) != %clr_own) { &lt;br /&gt;
       hadd chess.info log_ep 1&lt;br /&gt;
       hdel chess.board %xy-1 &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y-1) 0 $get_square(%x) $get_square(%y-1) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info en_passant&lt;br /&gt;
     hdel chess.info check&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take $v1 }&lt;br /&gt;
     .echo -qg $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     clear_selections %current_selections %last.xy&lt;br /&gt;
     hdel chess.info selected&lt;br /&gt;
     hdel chess.info current_selections&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$hget(chess.info,king_in_danger)) {&lt;br /&gt;
       if (!$hget(chess.info,just_switched)) { chess_send move %last.xy2 %xy2 }&lt;br /&gt;
       print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
       hdel chess.info own_turn&lt;br /&gt;
     }&lt;br /&gt;
     hdel chess.info just_switched  &lt;br /&gt;
     hdel chess.info king_in_danger&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; nothing selected, so we&#039;re selecting a piece&lt;br /&gt;
   else {&lt;br /&gt;
     var %piece = $hget(chess.board,%xy)&lt;br /&gt;
     draw_selection %x %y green&lt;br /&gt;
     hadd chess.info selected 1&lt;br /&gt;
     chess_piece_options %piece %x %y&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info clr_moved %clr_selected&lt;br /&gt;
   hadd chess.info last.x %x&lt;br /&gt;
   hadd chess.info last.y %y&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_piece {&lt;br /&gt;
   var %y = $calc((($replace($left($3,1),w,1,b,3) + $iif($4 == 10407679,0,1)) *100) -100) &lt;br /&gt;
   var %x = $calc($replace($right($3,-2),pawn,0,rook,1,knight,2,bishop,3,queen,4,king,5) *100)&lt;br /&gt;
   drawpic -cms @chess $1 $2 $hget(chess.options,size) $hget(chess.options,size) %x %y 100 100 $qt($mircdirchess/pieces.png)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw_selection {&lt;br /&gt;
   if ($3 == red) &amp;amp;&amp;amp; (!$hget(chess.options,frames)) { return }&lt;br /&gt;
   drawrect -r @chess $clr_replace($3) 3 $calc($get_square($1) +1) $calc($get_square($2) +1) $calc($hget(chess.options,size) -2) $calc($hget(chess.options,size) -2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_move {&lt;br /&gt;
   var %piece = $hget(chess.board,$1)&lt;br /&gt;
   var %move_len = $abs($calc($left($3,1) - $left($1,1)))&lt;br /&gt;
 &lt;br /&gt;
   if ($right(%piece,-2) == pawn) {&lt;br /&gt;
     var %l.x = $mid($3,2,1)&lt;br /&gt;
     var %l.y = $mid($3,1,1)&lt;br /&gt;
     var %l.y-1 = $calc(%l.y -1)&lt;br /&gt;
     var %l.xy-1 = $+(%l.y-1,%l.x)&lt;br /&gt;
 &lt;br /&gt;
     if ($istok(1 8,$left($3,1),32)) { &lt;br /&gt;
       var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
       var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
       var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
       var %n.x2 = $calc(9 - $mid($3,2,1))&lt;br /&gt;
       var %n.y2 = $calc(9 - $mid($3,1,1))&lt;br /&gt;
       var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
       .echo -qg $dialog(choose_piece,choose_piece) &lt;br /&gt;
       if ($hget(chess.info,mode) == mp) { chess_send switch %newpiece %n.xy2 %l.xy2 }&lt;br /&gt;
       switch_piece %newpiece $3 $1  &lt;br /&gt;
       hadd chess.info just_switched 1&lt;br /&gt;
 &lt;br /&gt;
       return &lt;br /&gt;
     }&lt;br /&gt;
     elseif (%move_len == 2) { hadd chess.info en_passant $3 }&lt;br /&gt;
  &lt;br /&gt;
     if ($hget(chess.info,opponent_move)) &amp;amp;&amp;amp; ($hget(chess.info,en_passant) == %l.xy-1) {&lt;br /&gt;
        hadd chess.info log_ep 1&lt;br /&gt;
        hdel chess.board %l.xy-1 &lt;br /&gt;
        drawrect -rf @chess $get_color(%l.x,%l.y-1) 0 $get_square(%l.x) $get_square(%l.y-1) $hget(chess.options,size) $hget(chess.options,size) &lt;br /&gt;
     } &lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),_king)) {&lt;br /&gt;
     hadd chess.info $+($1,_king_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 81) {&lt;br /&gt;
     hadd chess.info left_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif (%piece == $+($hget(chess.info,clr_own),rook)) &amp;amp;&amp;amp; ($1 == 88) {&lt;br /&gt;
     hadd chess.info right_rook_moved 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.board $3 %piece&lt;br /&gt;
   hdel chess.board $1&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %piece $mid($3,2,1) $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       hadd chess.info check 1&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif (!$hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) { &lt;br /&gt;
       var %checked 1      &lt;br /&gt;
       chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(+,$iif($hget(chess.info,take),x))&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
     var %n = 1&lt;br /&gt;
     hadd chess.info king_check 1&lt;br /&gt;
     while ($hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_,*),%n,w).data) {&lt;br /&gt;
       var %s = $v1&lt;br /&gt;
       if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
       inc %n&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       hadd chess.info king_in_danger 1&lt;br /&gt;
     }&lt;br /&gt;
     elseif (!$hget(chess.info,just_switched)) &amp;amp;&amp;amp; (!%checked) { chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $iif($hget(chess.info,take),x) } &lt;br /&gt;
 &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,king_in_danger)) {&lt;br /&gt;
     print_info red Illegal move! king would be threated.&lt;br /&gt;
     hadd chess.board $1 %piece&lt;br /&gt;
     if ($hget(chess.info,take)) { hadd chess.board $3 $v1 }&lt;br /&gt;
     else { hdel chess.board $3 }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hdel chess.info just_switched&lt;br /&gt;
     hdel chess.info take&lt;br /&gt;
     hdel chess.info log_ep&lt;br /&gt;
     hdel chess.info opponent_move&lt;br /&gt;
   }&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 &lt;br /&gt;
   return&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l switch_piece {&lt;br /&gt;
   var %x = $mid($2,1,1)&lt;br /&gt;
   var %y = $mid($2,2,1)&lt;br /&gt;
   var %dx = $get_square(%x)&lt;br /&gt;
   var %dy = $get_square(%y)&lt;br /&gt;
   var %piece = $hget(chess.board,$3)&lt;br /&gt;
 &lt;br /&gt;
   var %new_piece = $1&lt;br /&gt;
   hadd chess.board $2 %new_piece&lt;br /&gt;
   hdel chess.board $3&lt;br /&gt;
 &lt;br /&gt;
   draw_piece %dy %dx %new_piece $get_color(%x,%y)  &lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
   chess_piece_options %new_piece %y %x&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check&lt;br /&gt;
       chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) $1 $3 $right(%piece,-2) $+(s,+,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2)&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) $3 $2 $right(%piece,-2) $+(s,$replace($hget(chess.info,take),1,x)) $right(%new_piece,-2) }&lt;br /&gt;
 &lt;br /&gt;
   unset %newpiece&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_castling {&lt;br /&gt;
   var %x.king = $mid($1,2,1)&lt;br /&gt;
   var %y.king = $mid($1,1,1)&lt;br /&gt;
   var %x.rook = $mid($2,2,1)&lt;br /&gt;
   var %y.rook = $mid($2,1,1)&lt;br /&gt;
 &lt;br /&gt;
   var %xy.king = $+(%y.king,%x.king)&lt;br /&gt;
   var %xy.rook = $+(%y.rook,%x.rook)&lt;br /&gt;
   var %king = $+($3,_king)&lt;br /&gt;
   var %rook = $+($3,_rook)&lt;br /&gt;
 &lt;br /&gt;
   var %l.x2 = $calc(9 - $mid($1,2,1))&lt;br /&gt;
   var %l.y2 = $calc(9 - $mid($1,1,1))&lt;br /&gt;
   var %l.xy2 = $+(%l.y2,%l.x2)&lt;br /&gt;
 &lt;br /&gt;
   var %n.x2 = $calc(9 - $mid($2,2,1))&lt;br /&gt;
   var %n.y2 = $calc(9 - $mid($2,1,1))&lt;br /&gt;
   var %n.xy2 = $+(%n.y2,%n.x2)&lt;br /&gt;
 &lt;br /&gt;
   if ($3 == $hget(chess.info,clr_own)) {&lt;br /&gt;
     hadd chess.info king_moved 1&lt;br /&gt;
     hadd chess.info $+($iif(%x.rook == 8,right,left),_rook_moved) 1&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if (%x.rook == 8) {&lt;br /&gt;
     var %x+1.king = $calc(%x.king +2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king +1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0,0-0-0)&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     var %x+1.king = $calc(%x.king -2)&lt;br /&gt;
     var %xy+1.king = $+(%y.king,%x+1.king)&lt;br /&gt;
     var %x-1.king = $calc(%x.king -1)&lt;br /&gt;
     var %xy-1.king = $+(%y.king,%x-1.king)&lt;br /&gt;
     var %castling = $iif($hget(chess.info,clr_own) == w,0-0-0,0-0)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     ;draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
     ;draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   draw_piece $get_square(%x+1.king) $get_square(%y.king) %king $get_color(%x+1.king,%y.king)&lt;br /&gt;
   draw_piece $get_square(%x-1.king) $get_square(%y.king) %rook $get_color(%x-1.king,%y.king)&lt;br /&gt;
 &lt;br /&gt;
   drawrect -rf @chess $get_color(%x.rook,%y.rook) 0 $get_square(%x.rook) $get_square(%y.rook) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
   drawrect -rf @chess $get_color(%x.king,%y.king) 0 $get_square(%x.king) $get_square(%y.king) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.board %xy+1.king %king&lt;br /&gt;
   hadd chess.board %xy-1.king %rook&lt;br /&gt;
   hdel chess.board %xy.rook&lt;br /&gt;
   hdel chess.board %xy.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,mode) == mp) &amp;amp;&amp;amp; (!$4) { &lt;br /&gt;
     chess_send castling %l.xy2 %n.xy2 $3&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) $+ &#039;s turn&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   hadd chess.info king_check 1&lt;br /&gt;
   hadd chess.info king_check2 1&lt;br /&gt;
 &lt;br /&gt;
   var %piece = %rook&lt;br /&gt;
   chess_piece_options %piece %x-1.king %y.king&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.info,opponent_move)) {&lt;br /&gt;
     if ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($hget(chess.info,clr_own),_king),1).data,32)) { &lt;br /&gt;
       print_info red Check | chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling +&lt;br /&gt;
     }&lt;br /&gt;
     else { chess_log $replacex($hget(chess.info,clr_own),b,w,w,b) %castling }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($istok($hget(chess.info,threat_zone),$hfind(chess.board,$+($iif($hget(chess.info,clr_own) == w,b,w),_king),1).data,32)) {  &lt;br /&gt;
     chess_log $hget(chess.info,clr_own) %castling +&lt;br /&gt;
   }&lt;br /&gt;
   else { chess_log $hget(chess.info,clr_own) %castling }&lt;br /&gt;
 &lt;br /&gt;
   hdel chess.info just_switched&lt;br /&gt;
   hdel chess.info take&lt;br /&gt;
   hdel chess.info log_ep&lt;br /&gt;
   hdel chess.info opponent_move&lt;br /&gt;
   hdel chess.info threat_zone&lt;br /&gt;
   hdel chess.info king_check&lt;br /&gt;
   hdel chess.info king_check2&lt;br /&gt;
   hdel chess.info own_turn&lt;br /&gt;
   hdel chess.info castling&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clr_replace {&lt;br /&gt;
   return $replacex($1,red,255,green,65280,blue,16732457,yellow,2751743,light_blue,16749691,white,16777215)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_color {&lt;br /&gt;
   ;return $iif($calc(($1 -($2 % 2)) % 2),0,16777215)&lt;br /&gt;
   return $iif($calc(($1 -($2 % 2)) % 2),4688849,10407679)&lt;br /&gt;
   ; 10407679&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias get_piece {&lt;br /&gt;
   if ($istok(1 2 7 8,$1,32)) { &lt;br /&gt;
     var %c = $hget(chess.info,clr_own)&lt;br /&gt;
     if ($1 == 2) { return $+($iif(%c == w,b,w),_pawn) }&lt;br /&gt;
     elseif ($1 == 7) { return $+(%c,_pawn) }&lt;br /&gt;
     elseif ($1 == 8) { return $+(%c,$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
     else { return $+($iif(%c == w,b,w),$gettok(_rook _knight _bishop $iif(%c == w,_queen _king,_king _queen) _bishop _knight _rook,$2,32)) }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l get_square {&lt;br /&gt;
   return $calc((($1 -1) * $hget(chess.options,size)) +20)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l clear_selections {&lt;br /&gt;
   var %z = 1 &lt;br /&gt;
   while ($gettok($1-,%z,32)) {&lt;br /&gt;
     var %x = $mid($v1,2,1)&lt;br /&gt;
     var %y = $mid($v1,1,1)&lt;br /&gt;
     var %ispiece = $hget(chess.board,$v1)&lt;br /&gt;
     if ($v1 != 99) { &lt;br /&gt;
       drawrect -rf @chess $get_color(%x,%y) 0 $get_square(%x) $get_square(%y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
       if (%ispiece) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     }&lt;br /&gt;
     inc %z&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_info {&lt;br /&gt;
   drawrect -rf @chess 3684408 0 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 | drawtext -cro @chess $clr_replace($1) &amp;quot;courier new&amp;quot; $iif($hget(chess.options,size) == 100,16,12) 20 $iif($hget(chess.options,size) == 100,825,505) $iif($hget(chess.options,size) == 100,570,420) 20 $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l check_square {&lt;br /&gt;
   var %hg = $hget(chess.board,$+($2,$1))&lt;br /&gt;
   var %c = $iif($hget(chess.info,clr_own) == w,b,w)&lt;br /&gt;
   if ($hget(chess.info,king_check)) { var %c = $iif(%c == w,b,w) }&lt;br /&gt;
   if ($3) { var %c = $3 }&lt;br /&gt;
   if (!%hg) || ($left(%hg,1) == %c) { &lt;br /&gt;
     return $true &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l in_board {&lt;br /&gt;
   if ($1 isnum 1-8) &amp;amp;&amp;amp; ($2 isnum 1-8) { return $true }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l draw+select {&lt;br /&gt;
   if (!$hget(chess.info,king_check)) { draw_selection $1 $2 $hget(chess.info,clr_select) }&lt;br /&gt;
   return $+($2,$1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options_rec {&lt;br /&gt;
   chess_piece_options $1-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l fw { return $calc($1 $iif($3 == w,+,-) $2) }&lt;br /&gt;
 alias -l bw { return $calc($1 $iif($3 == w,-,+) $2) }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_piece_options {&lt;br /&gt;
   var %king_check = $hget(chess.info,king_check)&lt;br /&gt;
   var %king_check2 = $hget(chess.info,king_check2) &lt;br /&gt;
 &lt;br /&gt;
   var %piece = $right($1,-2)&lt;br /&gt;
   var %clr_own = $left($1,1)&lt;br /&gt;
 &lt;br /&gt;
   if (!%king_check) {&lt;br /&gt;
     var %clr_own = $iif(%clr_own == w,w,b)&lt;br /&gt;
     var %clr_opponent = $iif(%clr_own == w,b,w)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   var %clr_opponent = $iif(%clr_own == w,b,w) &lt;br /&gt;
 &lt;br /&gt;
   var %x = $2&lt;br /&gt;
   var %y = $3&lt;br /&gt;
 &lt;br /&gt;
   ; PAWN&lt;br /&gt;
   if (%piece == pawn) { &lt;br /&gt;
 &lt;br /&gt;
     var %y+1 = $iif(%clr_own == w,$bw(%y,1,%clr_own),$fw(%y,1,%clr_own))&lt;br /&gt;
     var %y-1 = $iif(%clr_own == w,$fw(%y,1,%clr_own),$bw(%y,1,%clr_own))&lt;br /&gt;
     var %y+2 = $iif(%clr_own == w,$bw(%y,2,%clr_own),$fw(%y,2,%clr_own))&lt;br /&gt;
     var %x+1 = $calc(%x +1)&lt;br /&gt;
     var %x-1 = $calc(%x -1)&lt;br /&gt;
 &lt;br /&gt;
     var %take_left = $+(%y+1,%x+1)&lt;br /&gt;
     var %take_right = $+(%y+1,%x-1)&lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_left),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x+1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x+1)),1) == %clr_opponent))) {    &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x+1,%y+1,%x) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x+1,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (($left($hget(chess.board,%take_right),1) == %clr_opponent) || (($hget(chess.info,en_passant) == $+(%y,%x-1)) &amp;amp;&amp;amp; ($left($hget(chess.board,$+(%y,%x-1)),1) == %clr_opponent))) { &lt;br /&gt;
       if (!%king_check) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
     }&lt;br /&gt;
     if (%king_check) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     if (!$hget(chess.board,$+(%y+1,%x))) &amp;amp;&amp;amp; (%y+1 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+1 &amp;gt;= 1) &amp;amp;&amp;amp; (!%king_check) {&lt;br /&gt;
       var %select = %select $draw+select(%x,%y+1)&lt;br /&gt;
 &lt;br /&gt;
       ; 2 steps for first move&lt;br /&gt;
       if ($istok(2 7,%y,32)) &amp;amp;&amp;amp; (!$hget(chess.board,$+(%y+2,%x))) &amp;amp;&amp;amp; (%y+2 &amp;lt;= 8) &amp;amp;&amp;amp; (%y+2 &amp;gt; 1) { var %select = %select $draw+select(%x,%y+2) }&lt;br /&gt;
     }&lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; ROOK&lt;br /&gt;
   elseif (%piece == rook) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z } &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; BISHOP&lt;br /&gt;
   elseif (%piece == bishop) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; QUEEN&lt;br /&gt;
   elseif (%piece == queen) {&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     var %z = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | inc %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     var %z = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%y,%z)) { break } | var %select = %select $draw+select(%z,%y) | dec %z }    &lt;br /&gt;
     if ($left($hget(chess.board,$+(%y,%z)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%z,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     var %z = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%z &amp;gt;= 1) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | dec %z }   &lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     var %z = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%z &amp;lt;= 8) { if ($kc(%z,%x)) { break } | var %select = %select $draw+select(%x,%z) | inc %z }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%z,%x)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%x,%z) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;gt;= 1) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | dec %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;gt;= 1) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | dec %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     var %sx = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %sy = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     while (%sx &amp;lt;= 8) &amp;amp;&amp;amp; (%sy &amp;lt;= 8) { if ($kc(%sy,%sx)) { break } | var %select = %select $draw+select(%sx,%sy) | inc %sx | inc %sy }&lt;br /&gt;
     if ($left($hget(chess.board,$+(%sy,%sx)),1) == %clr_opponent) || (%king_check) { var %select = %select $draw+select(%sx,%sy) }&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KNIGHT&lt;br /&gt;
   elseif (%piece = knight) {&lt;br /&gt;
 &lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %x+2 = $iif(%x == 8,9,$calc(%x +2))&lt;br /&gt;
     var %x-2 = $iif(%x == 1,0,$calc(%x -2))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %y+2 = $iif(%y == 8,9,$calc(%y +2))&lt;br /&gt;
     var %y-2 = $iif(%y == 1,0,$calc(%y -2))&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y+2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y+2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y+1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y+1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 RIGHT-1&lt;br /&gt;
     if (($check_square(%x+1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x+1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-2 LEFT-1&lt;br /&gt;
     if (($check_square(%x-1,%y-2,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-2))) || (%king_check) { var %select = %select $draw+select(%x-1,%y-2) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 RIGHT-2&lt;br /&gt;
     if (($check_square(%x+2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x+2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x+2,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP-1 LEFT-2&lt;br /&gt;
     if (($check_square(%x-2,%y-1,%clr_opponent)) &amp;amp;&amp;amp; ($in_board(%x-2,%y-1))) || (%king_check) { var %select = %select $draw+select(%x-2,%y-1) } &lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; KING&lt;br /&gt;
   elseif (%piece == king) {&lt;br /&gt;
 &lt;br /&gt;
     var %x-1 = $iif(%x == 1,0,$calc(%x -1))&lt;br /&gt;
     var %y-1 = $iif(%y == 1,0,$calc(%y -1))&lt;br /&gt;
     var %x+1 = $iif(%x == 8,9,$calc(%x +1))&lt;br /&gt;
     var %y+1 = $iif(%y == 8,9,$calc(%y +1))&lt;br /&gt;
     var %xy = $+(%y,%x)&lt;br /&gt;
 &lt;br /&gt;
     if  (!%king_check) {&lt;br /&gt;
       var %n = 1&lt;br /&gt;
 &lt;br /&gt;
       hadd chess.info king_check 1&lt;br /&gt;
       while ($hfind(chess.board,$+(%clr_opponent,_,*),%n,w).data) {&lt;br /&gt;
         var %s = $v1&lt;br /&gt;
         if ($right($hget(chess.board,%s),-2) != king) { chess_piece_options_rec $hget(chess.board,%s) $mid(%s,2,1) $mid(%s,1,1) }&lt;br /&gt;
         inc %n&lt;br /&gt;
       }&lt;br /&gt;
       hdel chess.info king_check&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT&lt;br /&gt;
     if ($check_square(%x+1,%y)) &amp;amp;&amp;amp; ($in_board(%x+1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x+1),32)) { &lt;br /&gt;
       var %select = %select $draw+select(%x+1,%y) &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT&lt;br /&gt;
     if ($check_square(%x-1,%y)) &amp;amp;&amp;amp; ($in_board(%x-1,%y)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y,%x-1),32)) { var %select = %select $draw+select(%x-1,%y) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: UP&lt;br /&gt;
     if ($check_square(%x,%y-1)) &amp;amp;&amp;amp; ($in_board(%x,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x),32)) { var %select = %select $draw+select(%x,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: DOWN&lt;br /&gt;
     if ($check_square(%x,%y+1)) &amp;amp;&amp;amp; ($in_board(%x,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x),32)) { var %select = %select $draw+select(%x,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-UP&lt;br /&gt;
     if ($check_square(%x-1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: LEFT-DOWN&lt;br /&gt;
     if ($check_square(%x-1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x-1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x-1),32)) { var %select = %select $draw+select(%x-1,%y+1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-UP&lt;br /&gt;
     if ($check_square(%x+1,%y-1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y-1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y-1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y-1) }&lt;br /&gt;
 &lt;br /&gt;
     ; :: RIGHT-DOWN&lt;br /&gt;
     if ($check_square(%x+1,%y+1)) &amp;amp;&amp;amp; ($in_board(%x+1,%y+1)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+(%y+1,%x+1),32)) { var %select = %select $draw+select(%x+1,%y+1) } &lt;br /&gt;
 &lt;br /&gt;
     ; :: Castling&lt;br /&gt;
     if (!$hget(chess.info,king_moved)) {&lt;br /&gt;
       var %iy = 8&lt;br /&gt;
       var %lxy = $+(%iy,1)&lt;br /&gt;
       var %rxy = $+(%iy,8)&lt;br /&gt;
 &lt;br /&gt;
       if ($castling_left(%lxy,%iy,%clr_own)) { &lt;br /&gt;
         var %select = %select $draw+select(1,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }&lt;br /&gt;
       if ($castling_right(%rxy,%iy,%clr_own)) {&lt;br /&gt;
         var %select = %select $draw+select(8,%iy) &lt;br /&gt;
         hadd chess.info castling 1&lt;br /&gt;
       }      &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     hdel chess.info threat_zone&lt;br /&gt;
 &lt;br /&gt;
     if (!%king_check) { hadd chess.info current_selections $iif(%select,$v1,99) }&lt;br /&gt;
     else { hadd chess.info threat_zone $hget(chess.info,threat_zone) %select }&lt;br /&gt;
 &lt;br /&gt;
     return&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l kc {&lt;br /&gt;
   if ($hget(chess.info,king_check)) {&lt;br /&gt;
     if ($right($hget(chess.board,$+($1,$2)),-2) != king) &amp;amp;&amp;amp; ($hget(chess.board,$+($1,$2))) { return $true }&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($hget(chess.board,$+($1,$2))) {&lt;br /&gt;
     return $true&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_left {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,4))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,4),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,left_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,2))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,3))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,2),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,3),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias castling_right {&lt;br /&gt;
   if ($hget(chess.info,clr_own) == w) {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     if (!$hget(chess.info,right_rook_moved)) &amp;amp;&amp;amp; ($left($hget(chess.board,$1),1) == $3) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,6))) &amp;amp;&amp;amp; (!$hget(chess.board,$+($2,7))) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,5),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,6),32)) &amp;amp;&amp;amp; (!$istok($hget(chess.info,threat_zone),$+($2,7),32)) &amp;amp;&amp;amp; (!$hget(chess.info,check)) {&lt;br /&gt;
       return $true&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ;; SOCKETS, msg, notice&lt;br /&gt;
 &lt;br /&gt;
 #chess.n off&lt;br /&gt;
 on ^*:notice:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 on ^*:text:chess_game *:?:{&lt;br /&gt;
   if ($nick == $hget(chess.info,opponent)) { parse_incoming $2- | haltdef }&lt;br /&gt;
 }&lt;br /&gt;
 #chess.n end&lt;br /&gt;
 &lt;br /&gt;
 alias start_server {&lt;br /&gt;
   if ($hget(chess.info,con_type) != irc) {&lt;br /&gt;
     sockclose chess_connect&lt;br /&gt;
     socklisten chess_connect 6666&lt;br /&gt;
     hadd chess.info init 1&lt;br /&gt;
   }&lt;br /&gt;
   hadd chess.info clr_own w &lt;br /&gt;
   hadd chess.info mode mp &lt;br /&gt;
   hadd chess.info own_turn 1&lt;br /&gt;
   drawtext -ro @chess 16749691 verdana 22 60 $iif($hget(chess.options,size) == 100,560,380) waiting for other player...&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_to_server {&lt;br /&gt;
   sockopen chess %chess.ip %chess.port&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_send { &lt;br /&gt;
   if ($hget(chess.info,con_type) == irc) { &lt;br /&gt;
     var %m = $iif($hget(chess.options,send_method),$v1,msg)&lt;br /&gt;
     %m $hget(chess.info,opponent) chess_game $1- &lt;br /&gt;
   }&lt;br /&gt;
   else { sockwrite -n chess $1- }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:socklisten:chess_connect:{&lt;br /&gt;
   chess_initiate&lt;br /&gt;
   print_info light_blue You start.&lt;br /&gt;
   sockaccept chess&lt;br /&gt;
   chess_send init $me&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockopen:chess:{ &lt;br /&gt;
   chess_initiate &lt;br /&gt;
   chess_send init $me &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockread:chess:{ &lt;br /&gt;
   var %t&lt;br /&gt;
   sockread %t &lt;br /&gt;
   parse_incoming %t&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on *:sockclose:chess:{&lt;br /&gt;
   print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l parse_incoming {&lt;br /&gt;
   if ($active != chess) &amp;amp;&amp;amp; ($1 != cmsg) { flash @chess | titlebar @chess your turn! }&lt;br /&gt;
   tokenize 32 $1-&lt;br /&gt;
 &lt;br /&gt;
   if ($1 == init) { &lt;br /&gt;
     hadd chess.info opponent $2&lt;br /&gt;
     if (!$hget(chess.info,own_turn)) { print_info light_blue $2 starts. }&lt;br /&gt;
     if ($hget(chess.info,con_type) == irc) &amp;amp;&amp;amp; (!$hget(chess.info,init)) {&lt;br /&gt;
       hadd chess.info init 1      &lt;br /&gt;
       chess_initiate&lt;br /&gt;
       print_info light_blue You start.&lt;br /&gt;
       chess_send init $me&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == move) { &lt;br /&gt;
     hadd chess.info own_turn 1 &lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
 &lt;br /&gt;
     var %last.xy = $2&lt;br /&gt;
     var %last.x = $mid(%last.xy,2,1)&lt;br /&gt;
     var %last.y = $mid(%last.xy,1,1) &lt;br /&gt;
 &lt;br /&gt;
     var %xy = $3&lt;br /&gt;
     var %x = $mid(%xy,2,1)&lt;br /&gt;
     var %y = $mid(%xy,1,1)&lt;br /&gt;
 &lt;br /&gt;
     drawrect -rf @chess $get_color(%last.x,%last.y) 0 $get_square(%last.x) $get_square(%last.y) $hget(chess.options,size) $hget(chess.options,size)&lt;br /&gt;
     if ($hget(chess.board,%last.xy)) { draw_piece $get_square(%x) $get_square(%y) $v1 $get_color(%x,%y) }&lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,%xy)) { hadd chess.info take 1 }&lt;br /&gt;
     .echo -gq $chess_move(%last.xy,-&amp;gt;,%xy)&lt;br /&gt;
     draw_selection %last.x %last.y light_blue&lt;br /&gt;
     draw_selection %x %y yellow&lt;br /&gt;
     .timerclrlast $+ %xy 1 5 clear_selections %last.xy %xy&lt;br /&gt;
   } &lt;br /&gt;
   elseif ($1 == load) {&lt;br /&gt;
     print_info light_blue $hget(chess.info,opponent) loaded a game: $2 with $3&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == cmsg) {&lt;br /&gt;
     print_info yellow msg: $2-&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == disconnect) {&lt;br /&gt;
     print_info red $hget(chess.info,opponent) disconnected.&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == switch) {&lt;br /&gt;
     hadd chess.info opponent_move 1 &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     if ($hget(chess.board,$4)) { hadd chess.info take 1 }&lt;br /&gt;
     switch_piece $2-4&lt;br /&gt;
     clear_selections $4&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
   elseif ($1 == castling) { &lt;br /&gt;
     print_info light_blue Your turn.&lt;br /&gt;
     hadd chess.info opponent_move 1&lt;br /&gt;
     chess_castling $2-4 1&lt;br /&gt;
     hadd chess.info own_turn 1&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; LOGGING&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_show {&lt;br /&gt;
   window -C @chess $window(@chess).x $window(@chess).y $calc($window(@chess).w $1) $window(@chess).h&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l chess_log {&lt;br /&gt;
   if ($2 != 0-0) &amp;amp;&amp;amp; ($2 != 0-0-0) {&lt;br /&gt;
     var %x.from = $mid($2,2,1)&lt;br /&gt;
     var %x.to = $mid($3,2,1)&lt;br /&gt;
     var %y.from = $mid($2,1,1)&lt;br /&gt;
     var %y.to = $mid($3,1,1)&lt;br /&gt;
 &lt;br /&gt;
     if ($hget(chess.info,clr_own) == w) { &lt;br /&gt;
       var %y.from = $calc(9 - %y.from)&lt;br /&gt;
       var %y.to = $calc(9 - %y.to)&lt;br /&gt;
     }&lt;br /&gt;
     else { &lt;br /&gt;
       var %x.from = $calc(9 - %x.from)&lt;br /&gt;
       var %x.to = $calc(9 - %x.to)&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     var %x.from = $gettok(a b c d e f g h,%x.from,32)&lt;br /&gt;
     var %x.to = $gettok(a b c d e f g h,%x.to,32)&lt;br /&gt;
 &lt;br /&gt;
     var %from = $+(%x.from,%y.from)&lt;br /&gt;
     var %to = $+(%x.to,%y.to)&lt;br /&gt;
     var %p = $replace($4,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R)&lt;br /&gt;
     if ($hget(chess.options,log_format) == 1) { var %l = $+(%p,%from,$iif((x isin $5) || ($hget(chess.info,log_ep)),x,-),%to,$iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $+ $remove($5,x,s) $iif($hget(chess.info,log_ep),e.p.) }&lt;br /&gt;
     else { var %l = %p $upper(%from) $+ -&amp;gt; $+ $upper(%to) $iif(s isin $5,$replace($6,pawn,P,king,K,queen,Q,knight,N,bishop,B,rook,R))) $iif((x isin $5) || ($hget(chess.info,log_ep)),take) $replace($remove($5,x,s),+,check) $iif($hget(chess.info,log_ep),e.p.)  }  &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   else { var %l = $2 $+ $3 }&lt;br /&gt;
   print_last_move light_blue %l&lt;br /&gt;
   print_log $iif($1 == w,white,light_blue) %l&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_last_move {&lt;br /&gt;
   var %z = $width($2-,courier new,16)&lt;br /&gt;
   var %y = $calc($iif($hget(chess.options,size) == 100,820,500) - %z)&lt;br /&gt;
   drawrect -rf @chess 3684408 0 $iif($hget(chess.options,size) == 100,600,280) $iif($hget(chess.options,size) == 100,825,505) 225 20 | drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 %y $iif($hget(chess.options,size) == &lt;br /&gt;
 100,825,505) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l print_log {&lt;br /&gt;
   write chess\temp.log $1-&lt;br /&gt;
   if (!$hget(chess.info,log_shown)) { return }&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l filter_log {&lt;br /&gt;
   tokenize 32 $1&lt;br /&gt;
   hinc chess.info log_lines&lt;br /&gt;
   var %l = $hget(chess.info,log_lines)&lt;br /&gt;
 &lt;br /&gt;
   if (%l &amp;gt; $iif($hget(chess.options,size) == 100,40,24)) { drawscroll @chess 0 -20 $iif($hget(chess.options,size) == 100,840,520) 20 200 $iif($hget(chess.options,size) == 100,840,520) }&lt;br /&gt;
 &lt;br /&gt;
   drawtext -ro @chess $clr_replace($1) &amp;quot;Courier New&amp;quot; 16 $iif($hget(chess.options,size) == 100,840,520) $calc(0+(20 * $iif(%l &amp;lt;= $iif($hget(chess.options,size) == 100,40,24),%l,$v2) )) $2-&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 alias -l log_save {&lt;br /&gt;
   var %f = $+(chess/,$asctime(yyyy-mm-dd-hhnnss),-,$iif($hget(chess.info,mode) == sp,singleplayer,$hget(chess.info,opponent)),.log)&lt;br /&gt;
   filter -ff chess\temp.log %f&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; DIALOGS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 alias -l connect_dialog { .echo -gq $$dialog(chess_connect,chess_connect) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_connect {&lt;br /&gt;
   title &amp;quot;Create chess connection&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IP&amp;quot;, 1, 7 25 100 20, tab11&lt;br /&gt;
   text &amp;quot;PORT&amp;quot;, 2, 111 25 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 3, 5 42 100 20, tab11&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 108 42 100 20, tab11&lt;br /&gt;
   button &amp;quot;connect&amp;quot;, 5, 211 41 60 22,default&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC-nick to connect to&amp;quot;, 8, 7 25 150 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 9, 5 42 100 20 , tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:init:*:{&lt;br /&gt;
   did -a $dname 3 %chess.ip&lt;br /&gt;
   did -a $dname 4 $iif(%chess.port,$v1,6666)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_connect:sclick:5:{&lt;br /&gt;
   if ($dialog($dname).tab == 11) {&lt;br /&gt;
     set %chess.ip $did($dname,3)&lt;br /&gt;
     set %chess.port $did($dname,4)&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     connect_to_server&lt;br /&gt;
   }&lt;br /&gt;
   else {&lt;br /&gt;
     hadd chess.info init 1 | hadd chess.info clr_own b | hadd chess.info mode mp | hadd chess.info last_moved b | hadd chess.info opponent $did($dname,9)&lt;br /&gt;
     dialog -x chess_connect&lt;br /&gt;
     hadd chess.info con_type irc&lt;br /&gt;
     chess_send init $me&lt;br /&gt;
     chess_initiate&lt;br /&gt;
     .enable #chess.n&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_send_pm {&lt;br /&gt;
   title &amp;quot;Send a message&amp;quot;&lt;br /&gt;
   size -1 -1 275 50&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;&amp;quot;, 1, 7 5 250 20,&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 2, 5 25 200 20,&lt;br /&gt;
   button &amp;quot;send&amp;quot; 3, 211 25 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:init:*:{&lt;br /&gt;
   did -a $dname 1 Send a message to $hget(chess.info,opponent)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_send_pm:sclick:3:{&lt;br /&gt;
   dialog -x chess_send_pm&lt;br /&gt;
   chess_send cmsg $did($dname,2)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_getimg {&lt;br /&gt;
   title &amp;quot;Missing files&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;The file pieces.png doesn&#039;t seem to exist in your chess-directory, download it?&amp;quot;, 1, 7 5 270 30,&lt;br /&gt;
   text &amp;quot;&amp;quot;, 2, 7 50 250 20&lt;br /&gt;
   button &amp;quot;download&amp;quot; 3, 211 45 60 22,default&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_getimg:sclick:3:{&lt;br /&gt;
   if (!$hget(chess.info,retry)) { getimg | did -ra $dname 2 downloading... }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt; 5) { getimg }&lt;br /&gt;
   else { dialog -x $dname }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias -l server_dialog { .echo -gq $$dialog(chess_server,chess_server) }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_server {&lt;br /&gt;
   title &amp;quot;Start a chess server&amp;quot;&lt;br /&gt;
   size -1 -1 275 70&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   tab &amp;quot;Sockets&amp;quot;,  11, -1 -1 277 202&lt;br /&gt;
   tab &amp;quot;IRC&amp;quot;, 12, -1 -1 277 202&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Start a socket connection&amp;quot;, 1, 7 25 200 20, tab11&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 2, 5 41 60 22,default tab11&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Wait for a connection from nick...&amp;quot;, 3, 7 25 200 20, tab12&lt;br /&gt;
   edit &amp;quot;&amp;quot;, 4, 5 42 100 20 , tab12&lt;br /&gt;
   button &amp;quot;start&amp;quot;, 5, 108 41 60 22,default tab12&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:init:*:{&lt;br /&gt;
   did -a $dname 4 $iif(%chess.nick,$v1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:2:{&lt;br /&gt;
   start_server&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_server:sclick:5:{&lt;br /&gt;
   hadd chess.info con_type irc&lt;br /&gt;
   hadd chess.info opponent $did($dname,4)&lt;br /&gt;
   .enable #chess.n&lt;br /&gt;
   start_server &lt;br /&gt;
   set %chess.nick $did($dname,4)&lt;br /&gt;
   dialog -x $dname&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog choose_piece {&lt;br /&gt;
   title &amp;quot;Chess - choose new piece&amp;quot;&lt;br /&gt;
   size -1 -1 422 130&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Select a new piece.&amp;quot;,5, 7 5 417 20&lt;br /&gt;
   button &amp;quot;Queen&amp;quot; 1, 5 25 100 100&lt;br /&gt;
   button &amp;quot;Rook&amp;quot; 2, 108 25 100 100&lt;br /&gt;
   button &amp;quot;Bishop&amp;quot; 3, 211 25 100 100&lt;br /&gt;
   button &amp;quot;Knight&amp;quot; 4, 314 25 100 100&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:choose_piece:sclick:1,2,3,4:{&lt;br /&gt;
   set %newpiece $+($hget(chess.info,clr_own),_,$gettok(queen rook bishop knight,$did,32))&lt;br /&gt;
   dialog -x choose_piece&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dialog -l chess_options {&lt;br /&gt;
   title &amp;quot;Chess options&amp;quot;&lt;br /&gt;
   size -1 -1 400 400&lt;br /&gt;
   option pixels&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Logging format&amp;quot;, 1, 7 8 100 20&lt;br /&gt;
   combo 2, 110 5 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Square size (pixels)&amp;quot;, 3, 7 30 100 20&lt;br /&gt;
   combo 4, 110 27 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;IRC send method&amp;quot;, 5, 7 52 100 20&lt;br /&gt;
   combo 6, 110 49 200 20,drop&lt;br /&gt;
 &lt;br /&gt;
   text &amp;quot;Selection frames&amp;quot;, 7, 7 74 100 20&lt;br /&gt;
   check &amp;quot;&amp;quot; 8, 110 71 20 20,&lt;br /&gt;
 &lt;br /&gt;
   button &amp;quot;save&amp;quot;, 10, 330 370 60 22,ok&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:init:*:{&lt;br /&gt;
   did -a $dname 2 International (Pe2xf1Q+)&lt;br /&gt;
   did -a $dname 2 New (P E2-&amp;gt;F1 Q take+check)&lt;br /&gt;
   did -c $dname 2 $iif($hget(chess.options,log_format),$v1,1)&lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 4 100&lt;br /&gt;
   did -a $dname 4 60&lt;br /&gt;
   did -c $dname 4 $iif($hget(chess.options,size) == 100,1,2) &lt;br /&gt;
 &lt;br /&gt;
   did -a $dname 6 msg&lt;br /&gt;
   did -a $dname 6 notice&lt;br /&gt;
   did -c $dname 6 $iif($hget(chess.options,send_method) == msg,1,2)&lt;br /&gt;
 &lt;br /&gt;
   if ($hget(chess.options,frames)) { did -c $dname 8 }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on 1:dialog:chess_options:sclick:10:{&lt;br /&gt;
   hadd chess.options log_format $did($dname,2).sel&lt;br /&gt;
   if ($did($dname,4).seltext != $hget(chess.options,size)) { hadd chess.options size $did($dname,4).seltext | .timerrestart 1 0 chess_restart }&lt;br /&gt;
   if ($did($dname,8).state == 1) { hadd chess.options frames 1 }&lt;br /&gt;
   else { hdel chess.options frames }&lt;br /&gt;
   hadd chess.options send_method $did($dname,6)&lt;br /&gt;
 &lt;br /&gt;
   hsave chess.options chess/options.hsh&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; FETCH IMAGE&lt;br /&gt;
 alias getimg { &lt;br /&gt;
   if (!$exists(chess)) { mkdir chess }&lt;br /&gt;
   .remove $qt($mircdirchess/pieces.png) &lt;br /&gt;
   sockclose getimg &lt;br /&gt;
   sockopen getimg lost.kapsi.fi 80 &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockopen:getimg:{ &lt;br /&gt;
   sockwrite -nt getimg GET /cail/pieces.png HTTP/1.1 &lt;br /&gt;
   sockwrite -nt getimg Host: lost.kapsi.fi&lt;br /&gt;
   sockwrite -nt getimg Connection: close&lt;br /&gt;
   sockwrite -nt getimg $crlf &lt;br /&gt;
 }&lt;br /&gt;
 on *:sockread:getimg:{ &lt;br /&gt;
   if (!$sock(getimg).mark) { &lt;br /&gt;
     var %t&lt;br /&gt;
     sockread %t&lt;br /&gt;
     if ($gettok(%t,1,32) == Content-Length:) { var %content_len = $gettok(%t,2,32) }&lt;br /&gt;
   }&lt;br /&gt;
   if (!%t) { sockmark getimg $iif(%content_len,$v1,1) }&lt;br /&gt;
   if ($sock(getimg).mark) {&lt;br /&gt;
     sockread -f &amp;amp;img&lt;br /&gt;
     bwrite $qt($mircdirchess/pieces.png) -1 &amp;amp;img&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 on *:sockclose:getimg:{ &lt;br /&gt;
   if ($file($qt($mircdirchess/pieces.png)) == $sock(getimg).mark) || ($sock(getimg).mark == 1) { dialog -x chess_getimg }&lt;br /&gt;
   elseif ($hget(chess.info,retry) &amp;lt;= 5) { hinc chess.info retry | did chess_getimg 2 Error, trying again... ( $+ $hget(chess.info,retry) $+ ) | .remove $qt($mircdirchess/pieces.png) | getimg }&lt;br /&gt;
   else { did chess_getimg 2 5 retries gone, try again later }&lt;br /&gt;
   unset %content_len&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Help ==&lt;br /&gt;
&lt;br /&gt;
=== The game ===&lt;br /&gt;
&lt;br /&gt;
Singleplayer mode is only for debugging and testing, not actually to play. &lt;br /&gt;
This game is meant to be played as multiplayer, where other player starts a server (whites), &lt;br /&gt;
and other connects to this server (blacks) &lt;br /&gt;
&lt;br /&gt;
=== Server and connecting ===&lt;br /&gt;
&lt;br /&gt;
Two connection types are available, sockets and through IRC with /notice or /msg&lt;br /&gt;
Connection type must be same on both players, the one starting a server must start a server using sockets &lt;br /&gt;
(default), or from server dialog select IRC and input the other players nick (in active server connection)&lt;br /&gt;
&lt;br /&gt;
The connecting player must then select the same connection method from the connect dialog, and input&lt;br /&gt;
the servers IP (sockets) or NICK (IRC),&lt;br /&gt;
note that the same PORT must be used on both clients.&lt;br /&gt;
&lt;br /&gt;
=== Implemented rules === (read more about the rules from wikipedia)&lt;br /&gt;
&lt;br /&gt;
All the pieces move correctly, and you cannot make a move that wouldn&#039;t go by the rules.&lt;br /&gt;
Pawn can perform en passant move, and if advanced to the 8th rank (other side of the board), it gets promoted to queen,rook,bishop,knight of the same color.&lt;br /&gt;
King and rook can perform castling move, if all the requirements are met, selecting king will highlight the rook, if then clicked on the rook, the castling is performed.&lt;br /&gt;
IF king is in check, the game will show the selectiong borders in squares you cannot move, but won&#039;t let you move there if you try.&lt;br /&gt;
&lt;br /&gt;
=== Mouse &amp;amp; menus ===&lt;br /&gt;
&lt;br /&gt;
You select pieces by clicking them, and move them by clicking on the target square, clicking the selected piece will de-select it.&lt;br /&gt;
You&#039;ll find last move from bottom right hand side of the board, clicking it will append the log-window on the right side, where you will see&lt;br /&gt;
40 (with 100px squares) or 24 (60px squares) last moves, doubleclicking a move in the log-window will highlight the move on the board.&lt;br /&gt;
Right clicking anywhere brings you a popup-menu, where you will always find options and help, if in game, also save &amp;amp; load are in this menu.&lt;br /&gt;
If in multiplayer mode, there&#039;s also &amp;quot;send msg&amp;quot;, from where you can send a message to other players infobar (bottom left hand side on the board).&lt;br /&gt;
Right clicking on the log menu let&#039;s you save the log.&lt;br /&gt;
&lt;br /&gt;
=== Saving &amp;amp; loading ===&lt;br /&gt;
&lt;br /&gt;
You can save and load your gamestate, the game will create 2 files into your /chess-folder&lt;br /&gt;
YYYY-MM-DD-HHNNSS_board_OPPONENTSNAME.save and YYYY-MM-DD-HHNNSS_info_OPPONENTSNAME.save&lt;br /&gt;
There will be notification for you, if the opponent loads a game, telling you what game he/she loaded.&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
Logging format: let&#039;s you choose the logging format between &amp;quot;International (Pe2xf1Q+)&amp;quot; and &amp;quot;New (P E2-&amp;gt;F1 Q take+check)&amp;quot;&lt;br /&gt;
Square size: Width &amp;amp; height of the squares in the board in pixels.&lt;br /&gt;
IRC send method: Uses /msg OPPONENT or /notice OPPONENT to send information if connected via IRC.&lt;br /&gt;
Selection frames: Switch on/off showing of the borders in squares where you can move.&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Archive]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=URL-logger&amp;diff=6240</id>
		<title>URL-logger</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=URL-logger&amp;diff=6240"/>
		<updated>2019-12-11T01:13:38Z</updated>

		<summary type="html">&lt;p&gt;Cail: Fixing delete from DB. no biggies.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; Screenshots:&amp;lt;br /&amp;gt;&lt;br /&gt;
 [[:Image:ss_url_color.jpg|Screenshot 1: Colored links]]&amp;lt;br /&amp;gt;&lt;br /&gt;
 [[:Image:ss_url_search.jpg|Screenshot 2: Links search]]&lt;br /&gt;
  &lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   &lt;br /&gt;
 ; &lt;br /&gt;
 ; URL-logger with colored and underlined links by Cail at Quakenet -&amp;gt; #help.script&lt;br /&gt;
 ;&lt;br /&gt;
 ; $urlc -alias will color and underline links from the input, and log them into a file for later searching&lt;br /&gt;
 ; Tested and works on mIRC 6.2 and above (i recommend using &amp;gt;6.21 for $regsubex to work correctly)&lt;br /&gt;
 ; &lt;br /&gt;
 ; This script uses spopup.dll (OPTIONAL! you only need this if you want a new popup with info and some new features.),&lt;br /&gt;
 ; to replace mirc&#039;s builtin url-popup&lt;br /&gt;
 ; spopup.dll is made by Saturn, and you can get it from http://www.xise.nl/mirc/&lt;br /&gt;
 ; NOTE! Depending on how your mIRC is set up, your working path might be mirc&#039;s root dir, or Users/AppData folder&lt;br /&gt;
 ; For example in Windows 7 the AppData folder would be: C:\Users\HappyUser\AppData\Roaming\mIRC&lt;br /&gt;
 ; Note this when placing the .dll somewhere and not giving full path in the script.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Formats recognized links like:&lt;br /&gt;
 ;   - &amp;lt;nowiki&amp;gt;&amp;quot;http://google.com&amp;quot;&amp;lt;/nowiki&amp;gt; -&amp;gt; &amp;lt;nowiki&amp;gt;http://google.com&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ;   - url(&#039;&amp;lt;nowiki&amp;gt;www.google.com&amp;lt;/nowiki&amp;gt;&#039;); -&amp;gt; &amp;lt;nowiki&amp;gt;www.google.com&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ;   - (&amp;lt;nowiki&amp;gt;www.google.com/ahihi(kiaa)&amp;lt;/nowiki&amp;gt;) -&amp;gt; &amp;lt;nowiki&amp;gt;www.google.com/ahihi(kiaa)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ;   &lt;br /&gt;
 ;   And some more cleanups, and adds &#039;&amp;lt;nowiki&amp;gt;http://&amp;lt;/nowiki&amp;gt;&#039; in front of &#039;&amp;lt;nowiki&amp;gt;www.&amp;lt;/nowiki&amp;gt;&#039; for storing.&lt;br /&gt;
 ;   so that &amp;lt;nowiki&amp;gt;www.google.com&amp;lt;/nowiki&amp;gt; and &amp;lt;nowiki&amp;gt;http://www.google.com&amp;lt;/nowiki&amp;gt; are treated as a same link, and stored only once&lt;br /&gt;
 ;&lt;br /&gt;
 ; Uses 3 different colors for coloring links:&lt;br /&gt;
 ;   1) new link - not found from the file&lt;br /&gt;
 ;   2) opened link - is found from the file, and you have opened it via mirc&lt;br /&gt;
 ;   3) old link - is found from the file, but you haven&#039;t opened it&lt;br /&gt;
 ;&lt;br /&gt;
 ; Fetches title of youtube video&#039;s:&lt;br /&gt;
 ;   - Gets title of the video and stores it into the links.db (for searching)&lt;br /&gt;
 ;   - Echo&#039;s the title under the link in chat&lt;br /&gt;
 ;   - Hold down ctrl key when pressing enter if you post a link, to /msg the title into the channel&lt;br /&gt;
 ;   - Fill %sendYTtitleChans with channels separated by spaces (eg. %sendYTtitleChans #chan1 #chan2) to automatically&lt;br /&gt;
 ;     send the title into the channel when ever a youtube link is posted.&lt;br /&gt;
 ;&lt;br /&gt;
 ; Thanks to:&lt;br /&gt;
 ;   - Saturn for the spopup.dll&lt;br /&gt;
 ;   - Msmo for the cleanup regex&lt;br /&gt;
 ;&lt;br /&gt;
 ; &lt;br /&gt;
 ; UPDATE 06/07/2014: Performance update!&lt;br /&gt;
 ;                     - Added hashtables to be used on regular checks, speeding up the normal link flow, no more slowdowns with hundreds of thousands of links&lt;br /&gt;
 ;                     - Changed youtube title fetcher to use youtube API for faster download &amp;amp; faster parsing&lt;br /&gt;
 ;                     - Some bug fixes and general performance improvements&lt;br /&gt;
 ; UPDATE 14/06/2013: Added support for fetching and storing title from youtube links&lt;br /&gt;
 ;                     - fetches youtube video&#039;s title, stores it into the logfile, echoes the title on the channel&lt;br /&gt;
 ;                     - hold down ctrl key when pressing enter, when you post a link, to send the title as /msg to the channel (overrides %sendYTtitleChans variable)&lt;br /&gt;
 ;                     - set %sendYTtitleChans variable for channels you want to /msg the title automatically when a link is posted&lt;br /&gt;
 ;                       (for example: %sendYTtitleChans #channel1 #channel2 #channel3) would send the title into the channel on those 3 channels&lt;br /&gt;
 ; UPDATE 17/06/2007: Updated regex (fixed &#039;&amp;lt;nowiki&amp;gt;www.someurl.com/something&#039;s_here&amp;lt;/nowiki&amp;gt;&#039; to show correctly), added a timer with 200ms delay&lt;br /&gt;
 ;                    into the on keyup event (to prevent filtering while writing fast).&lt;br /&gt;
 ; UPDATE 23/03/2007: Changed on keydown -&amp;gt; on keyup, much more efficient now, won&#039;t need so much checks, and allows you to&lt;br /&gt;
 ;                    insert text infront/into the middle of the line.&lt;br /&gt;
 ; UPDATE 29/01/2007: added a regex into on keydown event to halt the script if something else than \S was pressed&lt;br /&gt;
 ;                    (now holding down shift/alt/ctrl doesn&#039;t affect it), and optimized the on keydown event a bit.&lt;br /&gt;
 ; UPDATE 18/01/2007: added on input event for the search (optional), rearranged the dll-stuff into same place, &lt;br /&gt;
 ;                    fixed a bug that didn&#039;t color some opened links without http:// (only www.)&lt;br /&gt;
 ;                    fixed if (!$exists($spopupdll)) { return } from linkpopup to &#039;halt&#039; (now shows the original popup)&lt;br /&gt;
 ;                    added a $db alias to return the filename, users can choose their own path/filename for the file.&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  &lt;br /&gt;
 &lt;br /&gt;
 ; $db returns the name of the database file, change this to whatever you want&lt;br /&gt;
 alias -l db { return $qt($deltok($mircexe,-1,92) $+ \ $+ links.db) } &lt;br /&gt;
 &lt;br /&gt;
 ; on start event for creating and loading the hash table&lt;br /&gt;
 on *:start:{&lt;br /&gt;
   linkhash_load&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias linkhash_load {&lt;br /&gt;
   ; free the old hashtable if it exists, and hmake a new one&lt;br /&gt;
   if ($hget(links.hash)) { hfree links.hash }&lt;br /&gt;
   hmake links.hash 1000&lt;br /&gt;
 &lt;br /&gt;
   ; filter links from DB file to the hashtable&lt;br /&gt;
   filter -fk $db LinkHash_copy *&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 alias linkhash_copy {&lt;br /&gt;
   tokenize 32 $1&lt;br /&gt;
   hadd links.hash $strip($3) $1-&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; alias to open the links window, and filter all of the urls into it&lt;br /&gt;
 alias urllog { &lt;br /&gt;
   ; if the window isn&#039;t open, create it, -ea to create an editbox and activate the window&lt;br /&gt;
   ; filter will copy the lines from the file by a matchtext (* = everything), -fw = from File to Window, and -p = wrap the text&lt;br /&gt;
   if (!$window(@links)) { &lt;br /&gt;
     window -ea @links &lt;br /&gt;
     filter -fwp $db @links * &lt;br /&gt;
   } &lt;br /&gt;
 &lt;br /&gt;
   ; else the window is already open, so activate it&lt;br /&gt;
   else { window -a @links } &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 ; alias to return colorcodes for the script, change these values to whatever you like.&lt;br /&gt;
 ; new, old and opened are for echo text, log_link and log_info are for the @links window&lt;br /&gt;
 alias -l url_color {&lt;br /&gt;
   if ($1 == new) { return 12 }&lt;br /&gt;
   elseif ($1 == old) { return 6 }&lt;br /&gt;
   elseif ($1 == opened) { return 10 }&lt;br /&gt;
   elseif ($1 == log_link) { return 10 }&lt;br /&gt;
   elseif ($1 == log_info) { return 14 }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; $clr alias to return $chr(3) and formatted color code, ie. $clr(3) == $+($chr(3),03) == ctrl+k 03&lt;br /&gt;
 alias -l clr { if ($isid) { return $+($chr(3),$base($1,10,10,2)) $+ $iif($2,$+($chr(44),$base($2,10,10,2)),) } }&lt;br /&gt;
 &lt;br /&gt;
 ; this alias handles checking the input for links, looping through tokens (words in this case), and replacing links with colored ones&lt;br /&gt;
 alias urlc {&lt;br /&gt;
   if (!$isid) { return }&lt;br /&gt;
   var %string = $1-&lt;br /&gt;
 &lt;br /&gt;
   ; if the line even has links, useless to loop through it if there are no links&lt;br /&gt;
   if ($regex(%string,/(?:\b(?:www.?\.|https?:\/\/|s?ftp:\/\/).)/i)) { &lt;br /&gt;
 &lt;br /&gt;
     ; so the line has links, loop through tokens then&lt;br /&gt;
     var %x = 1 &lt;br /&gt;
     while (%x &amp;lt;= $numtok(%string,32)) { &lt;br /&gt;
 &lt;br /&gt;
       ; we&#039;ll assign the current token into a variable %tok, for easier use later&lt;br /&gt;
       ; and we&#039;ll run it through $url_parse, and assign the result into a variable %url &lt;br /&gt;
       ; (it&#039;ll be checked if it&#039;s a &#039;valid&#039; url, and useless stuff be removed around it, if it&#039;s not an url the alias will return $null&lt;br /&gt;
       var %tok = $gettok(%string,%x,32)&lt;br /&gt;
       var %url = $url_parse(%tok) &lt;br /&gt;
 &lt;br /&gt;
       ; check if there is an url in variable %url&lt;br /&gt;
       if (%url) { &lt;br /&gt;
 &lt;br /&gt;
         ; $url_log will take care of storing the url into a database file, and return appropriate color (in $1) to use in coloring the link&lt;br /&gt;
         ; also returns the linenumber of newly added link (in $2) if we want to store the title for it&lt;br /&gt;
         ; and if we already have the title in the log, return that too in %titleLine&lt;br /&gt;
         var %indb = $url_log(%url)&lt;br /&gt;
         var %linkColor = $gettok(%indb,1,32)&lt;br /&gt;
         var %titleLine = $gettok(%indb,2-,32)&lt;br /&gt;
 &lt;br /&gt;
         ; now we color and underline the url and assign it into %newurl, (%indb will be holding the color code number)&lt;br /&gt;
         ; then we replace the url part of the token, so that from &amp;quot;url(&#039;www.something.com&#039;);&amp;quot; only the &amp;quot;www.something.com&amp;quot; part will be colored and underlined&lt;br /&gt;
         var %newurl = $+($clr(%linkColor),$chr(31),%url,$chr(31),$clr)&lt;br /&gt;
         var %newurl = $replace(%tok,%url,%newurl) &lt;br /&gt;
 &lt;br /&gt;
         ; and finally, we put the modified token back to the original string&lt;br /&gt;
         %string = $puttok(%string,%newurl,%x,32)&lt;br /&gt;
 &lt;br /&gt;
         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; OPTIONAL: GET YOUTUBE TITLE &lt;br /&gt;
         ; this part is for checking if it&#039;s a youtube link, and initiates the fetching of the video&#039;s title&lt;br /&gt;
         ; this can be commented out or removed if you don&#039;t want this functionality&lt;br /&gt;
         if (*youtube* iswm %url) || (*youtu.be* iswm %url) {&lt;br /&gt;
           getTitle youtube %url $iif($chan,$chan,$iif($target != $me,$target,$nick)) %titleLine&lt;br /&gt;
         }&lt;br /&gt;
         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF OPTIONAL &lt;br /&gt;
       }&lt;br /&gt;
       inc %x &lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; modified or not, return the string&lt;br /&gt;
   return %string&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; alias to trim the given url, returns $null if input isn&#039;t an url&lt;br /&gt;
 ; big thanks to Msmo on Quakenet for this regex&lt;br /&gt;
 alias -l url_parse {&lt;br /&gt;
   var %p = /(?:^|[][()&amp;lt;&amp;gt;{}&#039;&amp;quot;\s])((?:(?:irc|s?ftp|https?:)\/\/|www\d*\.)[^\s./]+\.(?:\[\S*?]|\(\S*?\)|\{\S*?}|[^][()&amp;lt;&amp;gt;{}&#039;&amp;quot;\s]|[&#039;&amp;quot;](?!\s|$|[()\[\]&amp;lt;&amp;gt;]))++)/iS&lt;br /&gt;
   noop $regex($1,%p)&lt;br /&gt;
   return $regml(1)&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; alias to store the given url into database file, and return color according to whether it&#039;s new, opened, or unopened in database&lt;br /&gt;
 alias -l url_log {&lt;br /&gt;
   ; this first $iif is to append &amp;quot;http://&amp;quot; in front of &amp;quot;www.&amp;quot;, so &amp;quot;www.google.com&amp;quot; and &amp;quot;&amp;lt;nowiki&amp;gt;http://www.google.com&amp;lt;/nowiki&amp;gt;&amp;quot; will be a same link, and not to be written twice&lt;br /&gt;
   ; we&#039;ll assign the target channel/query into variable %t&lt;br /&gt;
   ; the $read will search the database file for the given url  &lt;br /&gt;
   var %url = $iif(www* iswm $1,$+(&amp;lt;nowiki&amp;gt;http://,$1&amp;lt;/nowiki&amp;gt;),$1)&lt;br /&gt;
   var %t = $iif($left($target,1) != $chr(35),query,$target)&lt;br /&gt;
   var %isOld = $hget(links.hash,%url)&lt;br /&gt;
 &lt;br /&gt;
   ; if %isOld is empty (the link wasn&#039;t found from the file), write it in there and return color of &amp;quot;new link&amp;quot; &amp;amp; the line number the link was added to&lt;br /&gt;
   ; also add the info to the hashtable&lt;br /&gt;
   if (!%isOld) { &lt;br /&gt;
     var %insertLine = $asctime(yyyy.mm.dd HH:nn:ss) $+($clr(03),$chr(31),%url,$chr(31),$clr()) $+($clr(07),$iif($nick,$nick,$me),$clr(08),@,$clr(07),%t,$clr()) &lt;br /&gt;
     write $db %insertLine&lt;br /&gt;
     hadd links.hash %url %insertLine&lt;br /&gt;
 &lt;br /&gt;
     return $url_color(new) $lines($db)&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; otherwise, if the link was found, check if it has been opened via mirc (4th word will be !), return color of &amp;quot;opened link&amp;quot;&lt;br /&gt;
   elseif ($gettok(%isOld,4,32) == !) { &lt;br /&gt;
     return $url_color(opened) __old %isOld&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; and if none of above, it&#039;s in the database, but you haven&#039;t opened it, return color of &amp;quot;old link&amp;quot;&lt;br /&gt;
   else { &lt;br /&gt;
     return $url_color(old) __old %isOld&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; this on keydown event triggers every time you press a key in @links window, &lt;br /&gt;
 ; and filters the database file into the window with the text in editbox&lt;br /&gt;
 ; so, performs a new search everytime you write something in that window, i like this kind of search, but you can make it with on input&lt;br /&gt;
 ; if you wish to use search with on input (searches when you press enter), disable #onKEYsearch -group (change &#039;on&#039; -&amp;gt; &#039;off&#039;)&lt;br /&gt;
 &lt;br /&gt;
 #onKEYsearch on&lt;br /&gt;
 on *:KEYUP:@links:*:{&lt;br /&gt;
   ; filter with the content of editbox&lt;br /&gt;
   ; timer to give a little delay for the filter (not filtering if writing fast), change the 200 (in milliseconds) to&lt;br /&gt;
   ; a bit higher value, if you&#039;re a slower writer.&lt;br /&gt;
   .timerURL -m 1 200 filter -cpfw $db @links $+(*,$editbox(@links),*)&lt;br /&gt;
 }&lt;br /&gt;
 #onKEYsearch end&lt;br /&gt;
 &lt;br /&gt;
 ; on input search for the @links window, if you want to use this instead of the on keydown, enable #onINPUTsearch -group (change &#039;off&#039; -&amp;gt; &#039;on&#039;)&lt;br /&gt;
 #onINPUTsearch off&lt;br /&gt;
 on *:INPUT:@links: {&lt;br /&gt;
   filter -cpfw $db @links $+(*,$1-,*)&lt;br /&gt;
 }&lt;br /&gt;
 #onINPUTsearch end&lt;br /&gt;
 &lt;br /&gt;
 ; on hotlink to trigger on links, this first one is for doubleclick&lt;br /&gt;
 on *$:HOTLINK:/((www.?\.|https?:\/\/|ftp:\/\/).)/i:*:{ &lt;br /&gt;
   ; clean up the triggered url with $url_parse and append &amp;quot;http://&amp;quot; in front of &amp;quot;www.&amp;quot; &lt;br /&gt;
   ; read the url info from database file, and if it doesn&#039;t have &#039;!&#039; as fourth token, add the &#039;!&#039; in there and write it back&lt;br /&gt;
   ; then open the url with url -n %url (change this, if you have your own alias for opening urls)&lt;br /&gt;
   var %url = $url_parse($1)&lt;br /&gt;
   var %url = $iif(www* iswm %url,$+(&amp;lt;nowiki&amp;gt;http://,%url&amp;lt;/nowiki&amp;gt;),%url)&lt;br /&gt;
 &lt;br /&gt;
   url -n %url &lt;br /&gt;
 &lt;br /&gt;
   var %oldurl = $read($db,w,$+(*,$chr(31),%url,$chr(31),*))&lt;br /&gt;
 &lt;br /&gt;
   if ($gettok(%oldurl,4,32) != !) {&lt;br /&gt;
     write $+(-l,$readn) $db $instok(%oldurl,!,4,32) &lt;br /&gt;
     hadd links.hash %url $instok(%oldurl,!,4,32)&lt;br /&gt;
   } &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; this second on hotlink is for the right click, shows the popup (leave it even if you&#039;re not going to use the spopup.dll)&lt;br /&gt;
 on ^*$:HOTLINK:/((www.?\.|https?:\/\/|ftp:\/\/).)/i:*:{ &lt;br /&gt;
   ; check if the spopup.dll file is in the right place, if not, halt so it&#039;ll show the default popup&lt;br /&gt;
   if (!$exists($spopupdll)) { halt } &lt;br /&gt;
 &lt;br /&gt;
   ; check if mouse button 2 have been pressed&lt;br /&gt;
   if ($mouse.key &amp;amp; 16) { popup_url $url_parse($1) }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 ;&lt;br /&gt;
 ; here starts the functionality with the spopup.dll&lt;br /&gt;
 ; you won&#039;t need this part if you don&#039;t want to use the dll&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 &lt;br /&gt;
 ; the path to spopup.dll (this default snipped uses the spopup.dll in the same folder where mirc.exe is located)&lt;br /&gt;
 alias -l spopupdll { return $qt($deltok($mircexe,-1,92) $+ \ $+ spopup.dll) }&lt;br /&gt;
 &lt;br /&gt;
 ; the new popup to replace the original one with a dll&lt;br /&gt;
 alias -l popup_url {&lt;br /&gt;
 &lt;br /&gt;
   ; strip colors etc. from given url ($1), and find the url info from the database file&lt;br /&gt;
   var %url = $strip($1)&lt;br /&gt;
   var %url2 = $strip($hget(links.hash,%url))&lt;br /&gt;
 &lt;br /&gt;
   ; assign the info variables&lt;br /&gt;
   var %datetime = $strip($gettok(%url2,1-2,32))&lt;br /&gt;
   var %nickchan = $strip($gettok(%url2,4-,32))&lt;br /&gt;
   var %nickchan = $iif($left(%nickchan,1) == !,$right(%nickchan,-2),%nickchan) &lt;br /&gt;
 &lt;br /&gt;
   ; show the popup&lt;br /&gt;
   dll $spopupdll clear&lt;br /&gt;
   dll $spopupdll add 1 0 0 open&lt;br /&gt;
   dll $spopupdll add 2 0 0 copy url&lt;br /&gt;
   dll $spopupdll add 3 0 0 copy info&lt;br /&gt;
   dll $spopupdll add 4 0 0 %datetime %nickchan&lt;br /&gt;
 &lt;br /&gt;
   ; show additional &amp;quot;remove item&amp;quot; if you are in the linklist&lt;br /&gt;
   if ($active == @links) {&lt;br /&gt;
     dll $spopupdll add 5 0 0 -&lt;br /&gt;
     dll $spopupdll add 6 0 16 remove url from db&lt;br /&gt;
     dll $spopupdll add 7 1 0 ok&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; assign the popup selection into a variable&lt;br /&gt;
   var %c =  $dll($spopupdll,popup,$mouse.cx $mouse.cy 1)&lt;br /&gt;
 &lt;br /&gt;
   ; check what the selection was&lt;br /&gt;
   ; these are the ID&#039;s from the popup, 2) copy url 3) copy info 4) the info (echo&#039;s the info into active) 7) remove link (only in @links window) &lt;br /&gt;
   if (%c == 1) { url -n %url }&lt;br /&gt;
   elseif (%c == 2) { clipboard %url }&lt;br /&gt;
   elseif (%c == 3) { clipboard %datetime %nickchan %url }&lt;br /&gt;
   elseif (%c == 4) { echo -agi30 url info: %datetime %nickchan %url }&lt;br /&gt;
   elseif (%c == 7) { elseif (%c == 7) { write $+(-dw*,%url,*) $db | LinkHash_Load }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 ;&lt;br /&gt;
 ; this section is for the title fetching (youtube only at this time)&lt;br /&gt;
 ; you won&#039;t need this part if you don&#039;t want to use the title fetching funcitonality&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 &lt;br /&gt;
 ; this is the output handler alias that gets called from different parts of the script, depending on if we&#039;re dealing with an old title or new&lt;br /&gt;
 alias titleOutput {&lt;br /&gt;
   ; format the title, we&#039;ll need timers here to output text _after_ the link has been processed and is echoed&lt;br /&gt;
   var %title = $replace($gettok($remtok($iif($4 == __new,$1-,$5-),!,1,32),5-,32),|,$!chr(124)) &lt;br /&gt;
 &lt;br /&gt;
   ; %inputSendLink will be true if you pressed enter holding down ctrl key, and it will message the title to the channel&lt;br /&gt;
   if (%inputSendLink) { &lt;br /&gt;
     .timerYTTitle $+ _msg_ $+ $2 -m 1 1 msg $3 Youtube: %title &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; checking if the channel where the link was posted, is in %sendYTtitleChans variable, if so, sends the title to the channel&lt;br /&gt;
   else if ($istok(%sendYTtitleChans,$3,32)) { &lt;br /&gt;
     .timerYTTitle $+ _msg_ $+ $2 -m 1 1 msg $3 Youtube: %title &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; echo the title of the link in the channel for you to see it&lt;br /&gt;
   .timerYTTitle $+ _echo_ $+ $2 -m 1 1 echo -t $3 Youtube: %title &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; a helper alias to clean HTML entities from the titles&lt;br /&gt;
 alias stripHTMLEntities { &lt;br /&gt;
   return $replace($1,&amp;amp;nbsp;,$chr(160),&amp;amp;quot;,&amp;quot;,&amp;amp;lt;,&amp;lt;,&amp;amp;gt;,&amp;gt;,&amp;amp;amp;,&amp;amp;, $&amp;amp;&lt;br /&gt;
     &amp;amp;pound;, $chr(163), &amp;amp;euro;, $chr(8364), &amp;amp;copy;, $chr(169), &amp;amp;trade, $chr(8482), &amp;amp;reg;, $chr(174))&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; alias to handle different possible sources for the title (youtube only for now)&lt;br /&gt;
 alias gettitle {&lt;br /&gt;
   ; first we check if we already have the title in the log, if so, use a quick timer to echo it out after the link&lt;br /&gt;
   if ($4 == __old) { &lt;br /&gt;
     titleOutput $1- &lt;br /&gt;
     return &lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   ; get the title for youtube links, also put some info on the sockmark, $2 = youtube URL, $3- = rest of the info&lt;br /&gt;
   else if ($1 == youtube) { &lt;br /&gt;
     var %sock = yttitle. $+ $ticks&lt;br /&gt;
     sockopen %sock gdata.youtube.com 80&lt;br /&gt;
     sockmark %sock $2 $3-&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; socket events for youtube - sockopen&lt;br /&gt;
 on *:sockopen:yttitle.*:{ &lt;br /&gt;
   if $sockerr { return }&lt;br /&gt;
 &lt;br /&gt;
   noop $regex($gettok($sock($sockname).mark,1,32),/(\?v=|&amp;amp;v=|\/\d\/|\/embed\/|\/v\/|\.be\/)([a-zA-Z0-9\-\_]{11})/)&lt;br /&gt;
 &lt;br /&gt;
   sockwrite -n $sockname GET /feeds/mobile/videos/ $+ $$regml(2) $+ ?v=2&amp;amp;prettyprint=true HTTP/1.1&lt;br /&gt;
   sockwrite -n $sockname Host: $sock($sockname).addr&lt;br /&gt;
   sockwrite -n $sockname $crlf&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ; socket events for youtube - sockread&lt;br /&gt;
 on *:sockread:yttitle.*:{ &lt;br /&gt;
   if $sockerr { return }&lt;br /&gt;
 &lt;br /&gt;
   var %data | sockread %data&lt;br /&gt;
 &lt;br /&gt;
   while ($sockbr) {&lt;br /&gt;
     if (*&amp;lt;title&amp;gt;*&amp;lt;/title&amp;gt;* iswm %data) { &lt;br /&gt;
       ; get the title &lt;br /&gt;
       var %title = $regsubex(%data,/(.*&amp;lt;title&amp;gt;|&amp;lt;/title&amp;gt;.*)/g,)&lt;br /&gt;
 &lt;br /&gt;
       ; send the title to titleOutput with other info&lt;br /&gt;
       titleOutput youtube $gettok($sock($sockname).mark,1,32) $gettok($sock($sockname).mark,2,32) __new %title&lt;br /&gt;
 &lt;br /&gt;
       ; if we set the linenumber info to the sockmark, we need to write the title into the DB file on that line&lt;br /&gt;
       if ($gettok($sock($sockname).mark,3,32)) {&lt;br /&gt;
         var %oldurl = $hget(links.hash,$gettok($sock($sockname).mark,1,32))&lt;br /&gt;
         write $+(-l,$v1) $db %oldurl %title&lt;br /&gt;
         hadd links.hash $gettok($sock($sockname).mark,1,32) %oldurl %title &lt;br /&gt;
       }&lt;br /&gt;
 &lt;br /&gt;
       sockclose $sockname&lt;br /&gt;
       return&lt;br /&gt;
     }&lt;br /&gt;
     sockread %data&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 ;&lt;br /&gt;
 ; the rest of the script is a part of my [[how to make your own theme]], and is only for an example usage of $urlc()&lt;br /&gt;
 ; basically you just need to run a line through $urlc() to color the links and log them&lt;br /&gt;
 ; you can add this into whatever event you like, ie. var %line = $urlc($1-) | echo %line&lt;br /&gt;
 ; this example also holds the if ($ctrlenter) { set %inputSendLink 1 } part, which is used in the title fetcher&lt;br /&gt;
 ;&lt;br /&gt;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
 &lt;br /&gt;
 on *:INPUT:*: {&lt;br /&gt;
   ; we will check that ctrl wasn&#039;t pressed while pressing enter, and that it&#039;s not a command&lt;br /&gt;
   if ($left($1,1) === $readini(mirc.ini,text,commandchar)) &amp;amp;&amp;amp; (!$ctrlenter) { return } &lt;br /&gt;
 &lt;br /&gt;
   ; check if ctrl was pressed while pressing enter, and store it in a variable (for sending title to the channel in case of a youtube link)&lt;br /&gt;
   unset %inputSendLink&lt;br /&gt;
   if ($ctrlenter) { set %inputSendLink 1 } &lt;br /&gt;
 &lt;br /&gt;
   ; halt the default actions&lt;br /&gt;
   haltdef&lt;br /&gt;
 &lt;br /&gt;
   ; we&#039;ll put the line into a variable, using $urlc() to store &amp;amp; color links if there are any&lt;br /&gt;
   var %line = $urlc($1-)&lt;br /&gt;
 &lt;br /&gt;
   ; here is the part what we send as msg, we want to send $1- and not the modified variable&lt;br /&gt;
   .msg $target $1-&lt;br /&gt;
 &lt;br /&gt;
   ; then we have the echo&lt;br /&gt;
   echo $color(own text) -at $+(&amp;lt;,$iif($chan,$nick($chan,$me).pnick,$me),&amp;gt;) %line &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 on ^*:TEXT:*:#: {&lt;br /&gt;
   ; halt the default actions and assign $1- into a variable, and run it through $urlc() to color the links and log them&lt;br /&gt;
   haltdef&lt;br /&gt;
   var %line = $urlc($1-) &lt;br /&gt;
 &lt;br /&gt;
   ; echo the text into a right channel, -m highlights the switchbar button with &amp;quot;message color&amp;quot;, -t adds timestamp&lt;br /&gt;
   echo $color(normal) -mlt $chan $+(&amp;lt;,$nick($chan,$nick).pnick,&amp;gt;) %line&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 on ^*:TEXT:*:?: {&lt;br /&gt;
   ; halt default actions, and set $1- into a variable, and run it through $urlc()&lt;br /&gt;
   haltdef&lt;br /&gt;
   var %line = $urlc($1-) &lt;br /&gt;
 &lt;br /&gt;
   ; echo the text into a right query &lt;br /&gt;
   echo $color(normal) -mlt $nick $+(&amp;lt;,$nick,&amp;gt;) %line&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Noob&amp;diff=6239</id>
		<title>Noob</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Noob&amp;diff=6239"/>
		<updated>2017-10-08T20:25:20Z</updated>

		<summary type="html">&lt;p&gt;Cail: Redirected page to How to start&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[How_to_start]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6238</id>
		<title>Start</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6238"/>
		<updated>2017-10-08T19:04:22Z</updated>

		<summary type="html">&lt;p&gt;Cail: Redirected page to How to start&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[How_to_start]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6237</id>
		<title>Start</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6237"/>
		<updated>2017-10-08T19:03:22Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[How_to_start]]&lt;br /&gt;
[[How_to_start (part 2)]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6236</id>
		<title>Start</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Start&amp;diff=6236"/>
		<updated>2017-10-08T19:02:49Z</updated>

		<summary type="html">&lt;p&gt;Cail: Redirected page to How to start&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[How_to_start]]&lt;br /&gt;
#REDIRECT [[How_to_start (part 2)]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Halp&amp;diff=6235</id>
		<title>Halp</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Halp&amp;diff=6235"/>
		<updated>2017-10-08T18:55:18Z</updated>

		<summary type="html">&lt;p&gt;Cail: Redirected page to Help&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Help]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Members&amp;diff=6234</id>
		<title>Category:Members</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Members&amp;diff=6234"/>
		<updated>2017-10-08T16:47:43Z</updated>

		<summary type="html">&lt;p&gt;Cail: /* Wiki Admins */  Removed Doomie, KreL1S and Zyberdog&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Wiki Admins ==&lt;br /&gt;
&lt;br /&gt;
* [[User:Albie|Albie]]&lt;br /&gt;
* [[User:Cail|Cail]]&lt;br /&gt;
* [[User:Jay2k1|Jay2k1]]&lt;br /&gt;
* [[User:Microbe|Microbe]]&lt;br /&gt;
* [[User:Saturn|Saturn]]&lt;br /&gt;
* [[User:Voronoi|Voronoi]]&lt;br /&gt;
* [[User:wiebe|wiebe]]&lt;br /&gt;
&lt;br /&gt;
== Wiki Editors ==&lt;br /&gt;
&lt;br /&gt;
* [[User:Aca20031|Aca20031]]&lt;br /&gt;
* [[User:Shenghi|Shenghi]]&lt;br /&gt;
* [[User:Vliedel|Vliedel]]&lt;br /&gt;
* [[User:bindi|bindi]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Members&amp;diff=6233</id>
		<title>Category:Members</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Members&amp;diff=6233"/>
		<updated>2017-10-08T16:45:50Z</updated>

		<summary type="html">&lt;p&gt;Cail: /* Wiki Editors */  Removed Tovrleaf, Shroud, Daveoh, Added bindi&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Wiki Admins ==&lt;br /&gt;
&lt;br /&gt;
* [[User:Albie|Albie]]&lt;br /&gt;
* [[User:Cail|Cail]]&lt;br /&gt;
* [[User:Doomie|Doomie]]&lt;br /&gt;
* [[User:Jay2k1|Jay2k1]]&lt;br /&gt;
* [[User:Kr3L1S|Kr3L1S]]&lt;br /&gt;
* [[User:Microbe|Microbe]]&lt;br /&gt;
* [[User:Saturn|Saturn]]&lt;br /&gt;
* [[User:Voronoi|Voronoi]]&lt;br /&gt;
* [[User:wiebe|wiebe]]&lt;br /&gt;
* [[User:Zyberdog|Zyberdog]]&lt;br /&gt;
&lt;br /&gt;
== Wiki Editors ==&lt;br /&gt;
&lt;br /&gt;
* [[User:Aca20031|Aca20031]]&lt;br /&gt;
* [[User:Shenghi|Shenghi]]&lt;br /&gt;
* [[User:Vliedel|Vliedel]]&lt;br /&gt;
* [[User:bindi|bindi]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6232</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6232"/>
		<updated>2017-08-21T21:03:08Z</updated>

		<summary type="html">&lt;p&gt;Cail: removing paste from sidepanel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|Main page&lt;br /&gt;
** news|News&lt;br /&gt;
** Categories|Categories&lt;br /&gt;
** Catstreelist|Category Tree&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=News&amp;diff=6231</id>
		<title>News</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=News&amp;diff=6231"/>
		<updated>2017-05-12T18:54:30Z</updated>

		<summary type="html">&lt;p&gt;Cail: Small edit.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Use ~ four times to get signature with timestamp, also available at the toolbar, second button from right --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Copy&amp;amp;Paste: {{newsWriter|~ four times}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 2017 Wiki overhaul ==&lt;br /&gt;
{{newsWriter|[[User:Cail|Cail]] ([[User talk:Cail|talk]]) 20:53, 12 May 2017 (CEST)}}&lt;br /&gt;
We have moved to a new home and updated the platform and the look of the wiki.&amp;lt;br&amp;gt;&lt;br /&gt;
Also mIRC has gotten some updates recently, as always, check http://www.mirc.com/whatsnew.txt to find out more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Wiki overhaul ==&lt;br /&gt;
{{newsWriter|[[User:Albie|Albie]] 22:49, 10 February 2011 (CET)}}&lt;br /&gt;
&lt;br /&gt;
The wiki has recently gone a huge overhaul is respect its codebase has been updated from MediaWiki version 1.4 to 1.16.&lt;br /&gt;
Hopefully most of the kinks have been worked out and everything is running smoothly :)&lt;br /&gt;
&lt;br /&gt;
== Wiki moved ==&lt;br /&gt;
&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 12:02, 2 Jul 2007 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
This Scriptwiki was moved to its new permanent home some time ago. The address is now easier to remember and it contains a hint of the wiki&#039;s origins.&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.21 is out ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 23:03, 23 Nov 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC version 6.21 was just released. Read more about it and download it at [http://www.mirc.com www.mirc.com].&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.2 is out ==&lt;br /&gt;
{{newsWriter|[[User:Cail|Cail]] 14:48, 27 Aug 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC 6.2 was released July 28th 2006, get it at [http://www.mirc.com www.mirc.com]. Take a look at the [http://www.mirc.co.uk/versions.txt list of changes] aswell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changes to Scriptwiki ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 00:39, 5 May 2006 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki has gone through some changes, again. It has been made an official QuakeNet wiki and recruiting new editors has been made easier - the process should now be far faster and more user-friendly. So if you&#039;re interested in contributing to this wiki, have a look at the front page&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.17 is out ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 00:31, 18 Feb 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC version 6.17 has been released an hour ago. Read more about it and download it at [http://www.mirc.com www.mirc.com].&lt;br /&gt;
&lt;br /&gt;
== Scriptwiki has been globalized ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 04:03, 4 Feb 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki has gone through some changes. The project started as a small one-channel project, but it is now released &amp;quot;to the wild&amp;quot;. People interested to contribute to this wiki are encouraged to contact us, especially from other networks than QuakeNet. At the moment this wiki is dedicated more towards QuakeNet users, but we are hoping that this will change in the future. Users from every network should be able to get the information they need from here, especially network-specific raw events.&lt;br /&gt;
&lt;br /&gt;
So if you want to contribute to the only wiki dedicated to mIRC scripting (at least at the moment), see the main page for more information.&lt;br /&gt;
&lt;br /&gt;
== Welcome to Scriptwiki ==&lt;br /&gt;
{{newsWriter|[[User:Tovrleaf|Tovrleaf]] 22:53, 15 Sep 2005 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Hi, and welcome to our new published &#039;&#039;&#039;Scriptwiki&#039;&#039;&#039;. Scriptwiki (as we call it) is our new lifelong project which won&#039;t probably ever be finished. It shall be developed and expanded along with mIRC and new scripting skills.&lt;br /&gt;
&lt;br /&gt;
Special thanks to all users who have helped us to get this to shape and to create a more user friendly wiki and articles.&lt;br /&gt;
&lt;br /&gt;
If you think this wiki is missing some essential articles, there&#039;s a page to [[Special:Request|request]] new articles for it. And don&#039;t forget to give us [[:Special:SendComment|feedback]], comments, ideas or new suggestions.&lt;br /&gt;
&lt;br /&gt;
== Scriptwiki starting ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 12:53, 24 Aug 2005 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki starting to get in shape&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=News&amp;diff=6230</id>
		<title>News</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=News&amp;diff=6230"/>
		<updated>2017-05-12T18:53:40Z</updated>

		<summary type="html">&lt;p&gt;Cail: Adding news about the overhaul.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Use ~ four times to get signature with timestamp, also available at the toolbar, second button from right --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Copy&amp;amp;Paste: {{newsWriter|~ four times}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 2017 Wiki overhaul ==&lt;br /&gt;
{{newsWriter|[[User:Cail|Cail]] ([[User talk:Cail|talk]]) 20:53, 12 May 2017 (CEST)}}&lt;br /&gt;
We have moved to a new home and updated the platform and the look of the wiki.&lt;br /&gt;
Also mIRC has gotten some updates recently, as always, check http://www.mirc.com/whatsnew.txt to find out more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Wiki overhaul ==&lt;br /&gt;
{{newsWriter|[[User:Albie|Albie]] 22:49, 10 February 2011 (CET)}}&lt;br /&gt;
&lt;br /&gt;
The wiki has recently gone a huge overhaul is respect its codebase has been updated from MediaWiki version 1.4 to 1.16.&lt;br /&gt;
Hopefully most of the kinks have been worked out and everything is running smoothly :)&lt;br /&gt;
&lt;br /&gt;
== Wiki moved ==&lt;br /&gt;
&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 12:02, 2 Jul 2007 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
This Scriptwiki was moved to its new permanent home some time ago. The address is now easier to remember and it contains a hint of the wiki&#039;s origins.&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.21 is out ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 23:03, 23 Nov 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC version 6.21 was just released. Read more about it and download it at [http://www.mirc.com www.mirc.com].&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.2 is out ==&lt;br /&gt;
{{newsWriter|[[User:Cail|Cail]] 14:48, 27 Aug 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC 6.2 was released July 28th 2006, get it at [http://www.mirc.com www.mirc.com]. Take a look at the [http://www.mirc.co.uk/versions.txt list of changes] aswell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changes to Scriptwiki ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 00:39, 5 May 2006 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki has gone through some changes, again. It has been made an official QuakeNet wiki and recruiting new editors has been made easier - the process should now be far faster and more user-friendly. So if you&#039;re interested in contributing to this wiki, have a look at the front page&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
== mIRC 6.17 is out ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 00:31, 18 Feb 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
mIRC version 6.17 has been released an hour ago. Read more about it and download it at [http://www.mirc.com www.mirc.com].&lt;br /&gt;
&lt;br /&gt;
== Scriptwiki has been globalized ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 04:03, 4 Feb 2006 (CET)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki has gone through some changes. The project started as a small one-channel project, but it is now released &amp;quot;to the wild&amp;quot;. People interested to contribute to this wiki are encouraged to contact us, especially from other networks than QuakeNet. At the moment this wiki is dedicated more towards QuakeNet users, but we are hoping that this will change in the future. Users from every network should be able to get the information they need from here, especially network-specific raw events.&lt;br /&gt;
&lt;br /&gt;
So if you want to contribute to the only wiki dedicated to mIRC scripting (at least at the moment), see the main page for more information.&lt;br /&gt;
&lt;br /&gt;
== Welcome to Scriptwiki ==&lt;br /&gt;
{{newsWriter|[[User:Tovrleaf|Tovrleaf]] 22:53, 15 Sep 2005 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Hi, and welcome to our new published &#039;&#039;&#039;Scriptwiki&#039;&#039;&#039;. Scriptwiki (as we call it) is our new lifelong project which won&#039;t probably ever be finished. It shall be developed and expanded along with mIRC and new scripting skills.&lt;br /&gt;
&lt;br /&gt;
Special thanks to all users who have helped us to get this to shape and to create a more user friendly wiki and articles.&lt;br /&gt;
&lt;br /&gt;
If you think this wiki is missing some essential articles, there&#039;s a page to [[Special:Request|request]] new articles for it. And don&#039;t forget to give us [[:Special:SendComment|feedback]], comments, ideas or new suggestions.&lt;br /&gt;
&lt;br /&gt;
== Scriptwiki starting ==&lt;br /&gt;
{{newsWriter|[[User:Microbe|Microbe]] 12:53, 24 Aug 2005 (CEST)}}&lt;br /&gt;
&lt;br /&gt;
Scriptwiki starting to get in shape&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Titlebar&amp;diff=6229</id>
		<title>Titlebar</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Titlebar&amp;diff=6229"/>
		<updated>2017-05-03T19:03:22Z</updated>

		<summary type="html">&lt;p&gt;Cail: Fixing bad formating&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sets the title of the main mIRC window, or a [[:Category:Custom Windows|custom window]].&lt;br /&gt;
&lt;br /&gt;
 /titlebar [@window] &amp;lt;title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If you do not specify a [[:Category:Custom Windows|custom window]], the main application title will change.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[$titlebar]]&lt;br /&gt;
* [[$window]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom Windows]] [[Category:Commands]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6228</id>
		<title>Category list</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6228"/>
		<updated>2017-05-02T20:17:31Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Agents =&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6227</id>
		<title>Category list</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6227"/>
		<updated>2017-05-02T20:17:10Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Agents =&lt;br /&gt;
A Microsoft Agent is the technical name for the little animated characters that Microsoft some times uses to help you with an application. For example, the little wizard when setting up Windows XP, or the paper clip in Microsoft Word. mIRC offers some commands to manipulate the Microsoft Agents for use in a script.&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6226</id>
		<title>Test mainpage</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6226"/>
		<updated>2017-05-02T20:12:47Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= This Wiki =&lt;br /&gt;
&lt;br /&gt;
Welcome to QuakeNet&#039;s Official Scriptwiki! This wiki provides you with all the necessary information to write your own scripts in mIRC&#039;s scripting language, and also offers a number of tutorials and pre-made scripts designed to make your daily life on QuakeNet easier.&lt;br /&gt;
&lt;br /&gt;
In contrast to many other wikis, normal users aren&#039;t allowed to make changes to this wiki. This way, we can ensure a certain level of quality. You are totally free to read the material, but if you want to contribute to this wiki, you have to ask an [[Members|admin]] on [http://webchat.quakenet.org/help.script #help.script] to add you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&#039;&#039;&#039;mIRC Help&#039;&#039;&#039; is based on [[mIRC]]&#039;s own help file.&lt;br /&gt;
It basically covers everything what can be found from the original help, but is commented and expanded with wiki staff [[:Category:Members|members]]&#039; knowledge, tutorials and scripting examples.&lt;br /&gt;
&lt;br /&gt;
[[:Category:MIRC Help|See mIRC Help]]&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
The Script Archive&#039;s purpose is to provide examples of how to use certain mIRC or ircd features. Before you try to use those scripts you should read them and make sure that you understand how they work. The comments in these scripts should help you with that.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Script Archive|See Script Archive]]&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
Our tutorials aim to provide a step-by-step introduction to various mIRC scripting related topics.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Tutorials|See Tutorials]]&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
We have also listed info on basic IRC commands.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Basic IRC commands|See Basic IRC commands]]&lt;br /&gt;
&lt;br /&gt;
= Other Stuff =&lt;br /&gt;
= Aliases =&lt;br /&gt;
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the &amp;quot;Aliases&amp;quot; section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the &amp;quot;Remote&amp;quot; section of the Scripts Editor. Creating an alias in the command line results in it being placed in the &amp;quot;Aliases&amp;quot; section of the Script Editor.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Aliases|See Aliases]]&lt;br /&gt;
&lt;br /&gt;
= RAWS =&lt;br /&gt;
When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Raws|See RAWs]]&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
QuakeNet is an IRC network, built around the gaming community, and is an organisation that facilitates the communication of many teams and online organisations. Though originally founded as a chat network for gamers, by gamers, QuakeNet welcomes everyone to chat about anything (within its rules). QuakeNet is also currently the largest chat network in the world, with a peak usercount each week of around 180,000 to 190,000 users (as listed by http://irc.netsplit.de/networks/).&lt;br /&gt;
IRC stands for &#039;Internet Relay Chat&#039;, and is a means for people to talk together in a text-based, real-time environment on the internet.&lt;br /&gt;
It has proven itself more popular than other chat systems, and more sophisticated, due in part to the ability to allow people to set up and keep their own rooms, or &#039;channels&#039;. Almost all IRC server software is open source, therefore even servers are available to anyone to set up. IRC networks are comprised of many linked servers, this means that when talking on the chat network, you can select a server closest to you and still talk to someone connected to a server on the other side of the world (as long as those servers are part of the same network, such as QuakeNet).Due to the nature and availability of IRC software and the protocols, IRC is controlled by no one person or organisation.&lt;br /&gt;
Whilst the vast majority of users on QuakeNet are gamers, QuakeNet is not limited to gaming-related topics, and we welcome all users who abide by our rules.&lt;br /&gt;
It&#039;s very simple to join in the fun. All you need is an IRC &#039;client&#039; (such as mIRC from www.mirc.com), you can then reach QuakeNet by selecting &amp;quot;QuakeNet: random server&amp;quot; from the server list, or by connecting directly to a server listed at http://www.quakenet.org/servers.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Quakenet|See Quakenet]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6225</id>
		<title>Test mainpage</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6225"/>
		<updated>2017-05-01T20:41:27Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= This Wiki =&lt;br /&gt;
&lt;br /&gt;
Welcome to QuakeNet&#039;s Official Scriptwiki! This wiki provides you with all the necessary information to write your own scripts in mIRC&#039;s scripting language, and also offers a number of tutorials and pre-made scripts designed to make your daily life on QuakeNet easier.&lt;br /&gt;
&lt;br /&gt;
In contrast to many other wikis, normal users aren&#039;t allowed to make changes to this wiki. This way, we can ensure a certain level of quality. You are totally free to read the material, but if you want to contribute to this wiki, you have to ask an [[Members|admin]] on [http://webchat.quakenet.org/help.script #help.script] to add you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&#039;&#039;&#039;mIRC Help&#039;&#039;&#039; is based on [[mIRC]]&#039;s own help file.&lt;br /&gt;
It basically covers everything what can be found from the original help, but is commented and expanded with wiki staff [[:Category:Members|members]]&#039; knowledge, tutorials and scripting examples.&lt;br /&gt;
&lt;br /&gt;
[[:Category:MIRC Help|See mIRC Help]]&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
The Script Archive&#039;s purpose is to provide examples of how to use certain mIRC or ircd features. Before you try to use those scripts you should read them and make sure that you understand how they work. The comments in these scripts should help you with that.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Script Archive|See Script Archive]]&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
Our tutorials aim to provide a step-by-step introduction to various mIRC scripting related topics.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Tutorials|See Tutorials]]&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
We have also listed info on basic IRC commands.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Basic IRC commands|See Basic IRC commands]]&lt;br /&gt;
&lt;br /&gt;
= Other Stuff =&lt;br /&gt;
= Aliases =&lt;br /&gt;
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the &amp;quot;Aliases&amp;quot; section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the &amp;quot;Remote&amp;quot; section of the Scripts Editor. Creating an alias in the command line results in it being placed in the &amp;quot;Aliases&amp;quot; section of the Script Editor.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Aliases|See Aliases]]&lt;br /&gt;
&lt;br /&gt;
= RAWS =&lt;br /&gt;
When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
[[:Category:RAWS|See RAWS]]&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
QuakeNet is an IRC network, built around the gaming community, and is an organisation that facilitates the communication of many teams and online organisations. Though originally founded as a chat network for gamers, by gamers, QuakeNet welcomes everyone to chat about anything (within its rules). QuakeNet is also currently the largest chat network in the world, with a peak usercount each week of around 180,000 to 190,000 users (as listed by http://irc.netsplit.de/networks/).&lt;br /&gt;
IRC stands for &#039;Internet Relay Chat&#039;, and is a means for people to talk together in a text-based, real-time environment on the internet.&lt;br /&gt;
It has proven itself more popular than other chat systems, and more sophisticated, due in part to the ability to allow people to set up and keep their own rooms, or &#039;channels&#039;. Almost all IRC server software is open source, therefore even servers are available to anyone to set up. IRC networks are comprised of many linked servers, this means that when talking on the chat network, you can select a server closest to you and still talk to someone connected to a server on the other side of the world (as long as those servers are part of the same network, such as QuakeNet).Due to the nature and availability of IRC software and the protocols, IRC is controlled by no one person or organisation.&lt;br /&gt;
Whilst the vast majority of users on QuakeNet are gamers, QuakeNet is not limited to gaming-related topics, and we welcome all users who abide by our rules.&lt;br /&gt;
It&#039;s very simple to join in the fun. All you need is an IRC &#039;client&#039; (such as mIRC from www.mirc.com), you can then reach QuakeNet by selecting &amp;quot;QuakeNet: random server&amp;quot; from the server list, or by connecting directly to a server listed at http://www.quakenet.org/servers.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Quakenet|See Quakenet]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6224</id>
		<title>Category list</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category_list&amp;diff=6224"/>
		<updated>2017-05-01T20:40:33Z</updated>

		<summary type="html">&lt;p&gt;Cail: Testing category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Agents =&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6223</id>
		<title>Test mainpage</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6223"/>
		<updated>2017-05-01T20:34:06Z</updated>

		<summary type="html">&lt;p&gt;Cail: I dunno what i&amp;#039;m doing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This Wiki ==&lt;br /&gt;
&lt;br /&gt;
Welcome to QuakeNet&#039;s Official Scriptwiki! This wiki provides you with all the necessary information to write your own scripts in mIRC&#039;s scripting language, and also offers a number of tutorials and pre-made scripts designed to make your daily life on QuakeNet easier.&lt;br /&gt;
&lt;br /&gt;
In contrast to many other wikis, normal users aren&#039;t allowed to make changes to this wiki. This way, we can ensure a certain level of quality. You are totally free to read the material, but if you want to contribute to this wiki, you have to ask an [[Members|admin]] on [http://webchat.quakenet.org/help.script #help.script] to add you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
&#039;&#039;&#039;mIRC Help&#039;&#039;&#039; is based on [[mIRC]]&#039;s own help file.&lt;br /&gt;
It basically covers everything what can be found from the original help, but is commented and expanded with wiki staff [[:Category:Members|members]]&#039; knowledge, tutorials and scripting examples.&lt;br /&gt;
&lt;br /&gt;
[[:Category:MIRC Help|See mIRC Help]]&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
The Script Archive&#039;s purpose is to provide examples of how to use certain mIRC or ircd features. Before you try to use those scripts you should read them and make sure that you understand how they work. The comments in these scripts should help you with that.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Script Archive|See Script Archive]]&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
Our tutorials aim to provide a step-by-step introduction to various mIRC scripting related topics.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Tutorials|See Tutorials]]&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
We have also listed info on basic IRC commands.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Basic IRC commands|See Basic IRC commands]]&lt;br /&gt;
&lt;br /&gt;
= Other Stuff =&lt;br /&gt;
= Aliases =&lt;br /&gt;
mIRC script allows you to create your own set of commands and identifiers, refered to as aliases. Aliases can be called from the command line, from other aliases, from popup and from remote scripts. An alias in mIRC can not be called recursively. They can be created by either putting them in the &amp;quot;Aliases&amp;quot; section of the mIRC Scripts Editor, by using the /alias command from either the command line or in the &amp;quot;Remote&amp;quot; section of the Scripts Editor. Creating an alias in the command line results in it being placed in the &amp;quot;Aliases&amp;quot; section of the Script Editor.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Aliases|See Aliases]]&lt;br /&gt;
&lt;br /&gt;
= RAWS =&lt;br /&gt;
When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
[[:Category:RAWS|See RAWS]]&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
QuakeNet is an IRC network, built around the gaming community, and is an organisation that facilitates the communication of many teams and online organisations. Though originally founded as a chat network for gamers, by gamers, QuakeNet welcomes everyone to chat about anything (within its rules). QuakeNet is also currently the largest chat network in the world, with a peak usercount each week of around 180,000 to 190,000 users (as listed by http://irc.netsplit.de/networks/).&lt;br /&gt;
IRC stands for &#039;Internet Relay Chat&#039;, and is a means for people to talk together in a text-based, real-time environment on the internet.&lt;br /&gt;
It has proven itself more popular than other chat systems, and more sophisticated, due in part to the ability to allow people to set up and keep their own rooms, or &#039;channels&#039;. Almost all IRC server software is open source, therefore even servers are available to anyone to set up. IRC networks are comprised of many linked servers, this means that when talking on the chat network, you can select a server closest to you and still talk to someone connected to a server on the other side of the world (as long as those servers are part of the same network, such as QuakeNet).Due to the nature and availability of IRC software and the protocols, IRC is controlled by no one person or organisation.&lt;br /&gt;
Whilst the vast majority of users on QuakeNet are gamers, QuakeNet is not limited to gaming-related topics, and we welcome all users who abide by our rules.&lt;br /&gt;
It&#039;s very simple to join in the fun. All you need is an IRC &#039;client&#039; (such as mIRC from www.mirc.com), you can then reach QuakeNet by selecting &amp;quot;QuakeNet: random server&amp;quot; from the server list, or by connecting directly to a server listed at http://www.quakenet.org/servers.&lt;br /&gt;
&lt;br /&gt;
[[:Category:Quakenet|See Quakenet]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6222</id>
		<title>Test mainpage</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Test_mainpage&amp;diff=6222"/>
		<updated>2017-05-01T19:57:19Z</updated>

		<summary type="html">&lt;p&gt;Cail: Created page with &amp;quot;== This Wiki ==  Welcome to QuakeNet&amp;#039;s Official Scriptwiki! This wiki provides you with all the necessary information to write your own scripts in mIRC&amp;#039;s scripting language, a...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This Wiki ==&lt;br /&gt;
&lt;br /&gt;
Welcome to QuakeNet&#039;s Official Scriptwiki! This wiki provides you with all the necessary information to write your own scripts in mIRC&#039;s scripting language, and also offers a number of tutorials and pre-made scripts designed to make your daily life on QuakeNet easier.&lt;br /&gt;
&lt;br /&gt;
In contrast to many other wikis, normal users aren&#039;t allowed to make changes to this wiki. This way, we can ensure a certain level of quality. You are totally free to read the material, but if you want to contribute to this wiki, you have to ask an [[Members|admin]] on [http://webchat.quakenet.org/help.script #help.script] to add you.&lt;br /&gt;
&lt;br /&gt;
== Script Archive ==&lt;br /&gt;
&lt;br /&gt;
You can find several prefabricated scripts in our [[:Category:Script Archive|Script Archive]], which serve as examples and can be used to build more complex scripts.&lt;br /&gt;
&lt;br /&gt;
== mIRC help ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re not sure how a command or an identifier works, you can check it from our [[:Category:MIRC_Help|mIRC Help]] pages.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Our [[:Category:Tutorials|tutorials]] aim to provide a step-by-step introduction to various mIRC scripting related topics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
This wiki is a project launched by [http://webchat.quakenet.org/help.script #help.script] on [http://www.quakenet.org QuakeNet].&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6221</id>
		<title>Category:Raws</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6221"/>
		<updated>2017-04-30T21:11:27Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To read more about the IRC RFC, look here: RFC 1459&lt;br /&gt;
&lt;br /&gt;
=== Syntax === &lt;br /&gt;
To actually react on numeric-raws, you have to use:&lt;br /&gt;
 raw [$]&amp;lt;numeric&amp;gt;:&amp;lt;matchtext&amp;gt;:{ commands }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that raw-events are just like &amp;quot;normal&amp;quot; events, like [[On_text|On Text]] or [[On_notice|On Notice]]. That means that you &#039;&#039;&#039;can&#039;t&#039;&#039;&#039; use them in an alias or in another event. If you are using &#039;&#039;$&#039;&#039; infront of the numeric, you have to use a regex-based matchtext.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
For example you get several numeric raws when you join a channel:&lt;br /&gt;
*[[Raw_332|332]] - containing the topic of the channel (like when using [[Topic|/topic]])&lt;br /&gt;
*[[Raw_333|333]] - containing the one who has set the topic and when it was set&lt;br /&gt;
*[[Raw_353|353]] - containing the names on the channel (like when using [[Names|/names]])&lt;br /&gt;
*[[Raw_366|366]] - containing the message that the list of names has ended&lt;br /&gt;
*[[Raw_324|324]] - containing the modes that are currently set (like when using [[Mode|/mode]])&lt;br /&gt;
*[[Raw_329|329]] - containing the creation date of the channel&lt;br /&gt;
&lt;br /&gt;
If you e.g. want to echo the creation date of the channel to your status window, you would have to use:&lt;br /&gt;
 ; raw 329 returns: &amp;lt;yournick&amp;gt; &amp;lt;#channel&amp;gt; &amp;lt;creation time in unix format&amp;gt;&lt;br /&gt;
 raw 329:*: {&lt;br /&gt;
  [[echo]] -a $2 was created at: [[$asctime]]($3)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to halt mIRC&#039;s default output in connection with a raw-event, you can use [[Haltdef|/haltdef]]. For example:&lt;br /&gt;
 raw 332:*: {&lt;br /&gt;
  haltdef&lt;br /&gt;
 }&lt;br /&gt;
This example would make mIRC not show the topic of a channel you have joined.&lt;br /&gt;
&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6220</id>
		<title>Category:Raws</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6220"/>
		<updated>2017-04-30T21:06:43Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To read more about the IRC RFC, look here: RFC 1459&lt;br /&gt;
&lt;br /&gt;
=== Syntax === &lt;br /&gt;
To actually react on numeric-raws, you have to use:&lt;br /&gt;
 raw [$]&amp;lt;numeric&amp;gt;:&amp;lt;matchtext&amp;gt;:{ commands }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that raw-events are just like &amp;quot;normal&amp;quot; events, like [[On_text|On Text]] or [[On_notice|On Notice]]. That means that you &#039;&#039;&#039;can&#039;t&#039;&#039;&#039; use them in an alias or in another event. If you are using &#039;&#039;$&#039;&#039; infront of the numeric, you have to use a regex-based matchtext.&lt;br /&gt;
&lt;br /&gt;
= Example =&lt;br /&gt;
For example you get several numeric raws when you join a channel:&lt;br /&gt;
*[[Raw_332|332]] - containing the topic of the channel (like when using [[Topic|/topic]])&lt;br /&gt;
*[[Raw_333|333]] - containing the one who has set the topic and when it was set&lt;br /&gt;
*[[Raw_353|353]] - containing the names on the channel (like when using [[Names|/names]])&lt;br /&gt;
*[[Raw_366|366]] - containing the message that the list of names has ended&lt;br /&gt;
*[[Raw_324|324]] - containing the modes that are currently set (like when using [[Mode|/mode]])&lt;br /&gt;
*[[Raw_329|329]] - containing the creation date of the channel&lt;br /&gt;
&lt;br /&gt;
If you e.g. want to echo the creation date of the channel to your status window, you would have to use:&lt;br /&gt;
 ; raw 329 returns: &amp;lt;yournick&amp;gt; &amp;lt;#channel&amp;gt; &amp;lt;creation time in unix format&amp;gt;&lt;br /&gt;
 raw 329:*: {&lt;br /&gt;
  [[echo]] -a $2 was created at: [[$asctime]]($3)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to halt mIRC&#039;s default output in connection with a raw-event, you can use [[Haltdef|/haltdef]]. For example:&lt;br /&gt;
 raw 332:*: {&lt;br /&gt;
  haltdef&lt;br /&gt;
 }&lt;br /&gt;
This example would make mIRC not show the topic of a channel you have joined.&lt;br /&gt;
&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6219</id>
		<title>Category:Raws</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6219"/>
		<updated>2017-04-30T21:06:21Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To read more about the IRC RFC, look here: RFC 1459&lt;br /&gt;
&lt;br /&gt;
=== Syntax === &lt;br /&gt;
To actually react on numeric-raws, you have to use:&lt;br /&gt;
 raw [$]&amp;lt;numeric&amp;gt;:&amp;lt;matchtext&amp;gt;:{ commands }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that raw-events are just like &amp;quot;normal&amp;quot; events, like [[On_text|On Text]] or [[On_notice|On Notice]]. That means that you &#039;&#039;&#039;can&#039;t&#039;&#039;&#039; use them in an alias or in another event. If you are using &#039;&#039;$&#039;&#039; infront of the numeric, you have to use a regex-based matchtext.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
For example you get several numeric raws when you join a channel:&lt;br /&gt;
*[[Raw_332|332]] - containing the topic of the channel (like when using [[Topic|/topic]])&lt;br /&gt;
*[[Raw_333|333]] - containing the one who has set the topic and when it was set&lt;br /&gt;
*[[Raw_353|353]] - containing the names on the channel (like when using [[Names|/names]])&lt;br /&gt;
*[[Raw_366|366]] - containing the message that the list of names has ended&lt;br /&gt;
*[[Raw_324|324]] - containing the modes that are currently set (like when using [[Mode|/mode]])&lt;br /&gt;
*[[Raw_329|329]] - containing the creation date of the channel&lt;br /&gt;
&lt;br /&gt;
If you e.g. want to echo the creation date of the channel to your status window, you would have to use:&lt;br /&gt;
 ; raw 329 returns: &amp;lt;yournick&amp;gt; &amp;lt;#channel&amp;gt; &amp;lt;creation time in unix format&amp;gt;&lt;br /&gt;
 raw 329:*: {&lt;br /&gt;
  [[echo]] -a $2 was created at: [[$asctime]]($3)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to halt mIRC&#039;s default output in connection with a raw-event, you can use [[Haltdef|/haltdef]]. For example:&lt;br /&gt;
 raw 332:*: {&lt;br /&gt;
  haltdef&lt;br /&gt;
 }&lt;br /&gt;
This example would make mIRC not show the topic of a channel you have joined.&lt;br /&gt;
&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6218</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6218"/>
		<updated>2017-04-30T20:28:22Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|Main page&lt;br /&gt;
** news|News&lt;br /&gt;
** Categories|Categories&lt;br /&gt;
** Catstreelist|Category Tree&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
** nopaste-url|nopaste&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Categories&amp;diff=6217</id>
		<title>Categories</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Categories&amp;diff=6217"/>
		<updated>2017-04-30T20:27:32Z</updated>

		<summary type="html">&lt;p&gt;Cail: Creating a new Category page with new name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Agents =&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
{{Category:Basic IRC commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
{{Category:Oper commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
{{Category:Quakenet}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
{{Category:Raws}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Quakenet&amp;diff=6216</id>
		<title>Category:Quakenet</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Quakenet&amp;diff=6216"/>
		<updated>2017-04-30T20:23:39Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;QuakeNet&#039;&#039;&#039; is an IRC network, built around the gaming community, and is an organisation that facilitates the communication of many teams and online organisations. Though originally founded as a chat network for gamers, by gamers, QuakeNet welcomes everyone to chat about anything (within its rules). QuakeNet is also currently the largest chat network in the world, with a peak usercount each week of around 180,000 to 190,000 users (as listed by [http://irc.netsplit.de/networks/ http://irc.netsplit.de/networks/]).&lt;br /&gt;
&lt;br /&gt;
[[:Category:IRC|IRC]] stands for &#039;Internet Relay Chat&#039;, and is a means for people to talk together in a text-based, real-time environment on the internet.&lt;br /&gt;
&lt;br /&gt;
It has proven itself more popular than other chat systems, and more sophisticated, due in part to the ability to allow people to set up and keep their own rooms, or &#039;channels&#039;. Almost all IRC server software is open source, therefore even servers are available to anyone to set up. IRC networks are comprised of many linked servers, this means that when talking on the chat network, you can select a server closest to you and still talk to someone connected to a server on the other side of the world (as long as those servers are part of the same network, such as QuakeNet).Due to the nature and availability of IRC software and the protocols, IRC is controlled by no one person or organisation.&lt;br /&gt;
&lt;br /&gt;
Whilst the vast majority of users on QuakeNet are gamers, QuakeNet is not limited to gaming-related topics, and we welcome all users who abide by our rules.&lt;br /&gt;
&lt;br /&gt;
It&#039;s very simple to join in the fun. All you need is an IRC &#039;client&#039; (such as [[mIRC]] from [http://www.mirc.com www.mirc.com]), you can then reach QuakeNet by selecting &amp;quot;QuakeNet: random server&amp;quot; from the server list, or by connecting directly to a server listed at [http://www.quakenet.org/servers http://www.quakenet.org/servers].&lt;br /&gt;
&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6215</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6215"/>
		<updated>2017-04-30T20:20:57Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Agents =&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
{{Category:Basic IRC commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
{{Category:Oper commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
{{Category:Quakenet}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
{{Category:Raws}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6214</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6214"/>
		<updated>2017-04-30T20:20:23Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Agents}}&lt;br /&gt;
&lt;br /&gt;
= Agents =&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= DDE =&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mIRC Help =&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Script Archives =&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Basic IRC commands =&lt;br /&gt;
{{Category:Basic IRC commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Oper commands =&lt;br /&gt;
{{Category:Oper commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Quakenet =&lt;br /&gt;
{{Category:Quakenet}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Raws =&lt;br /&gt;
{{Category:Raws}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6213</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=6213"/>
		<updated>2017-04-30T20:09:50Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|Main page&lt;br /&gt;
** news|News&lt;br /&gt;
** speccats|categories&lt;br /&gt;
** Catstreelist|Category Tree&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
** nopaste-url|nopaste&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Catstreelist&amp;diff=6212</id>
		<title>Catstreelist</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Catstreelist&amp;diff=6212"/>
		<updated>2017-04-30T20:09:19Z</updated>

		<summary type="html">&lt;p&gt;Cail: Page for the category tree listing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6211</id>
		<title>Category:Raws</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Category:Raws&amp;diff=6211"/>
		<updated>2017-04-30T20:01:15Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When the IRC server send you information it contains either a command or a RAW numeric. The numerics are a supplement to the normal events (NOTICE/PRIVMSG/MODE/etc.) not a replacement. Because raw events receive the information from the server in its native form, they give you maximum flexibility in regards to how you choose to use it or present it to the user of your script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To read more about the IRC RFC, look here: RFC 1459&lt;br /&gt;
&lt;br /&gt;
== Syntax== &lt;br /&gt;
To actually react on numeric-raws, you have to use:&lt;br /&gt;
 raw [$]&amp;lt;numeric&amp;gt;:&amp;lt;matchtext&amp;gt;:{ commands }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that raw-events are just like &amp;quot;normal&amp;quot; events, like [[On_text|On Text]] or [[On_notice|On Notice]]. That means that you &#039;&#039;&#039;can&#039;t&#039;&#039;&#039; use them in an alias or in another event. If you are using &#039;&#039;$&#039;&#039; infront of the numeric, you have to use a regex-based matchtext.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
For example you get several numeric raws when you join a channel:&lt;br /&gt;
*[[Raw_332|332]] - containing the topic of the channel (like when using [[Topic|/topic]])&lt;br /&gt;
*[[Raw_333|333]] - containing the one who has set the topic and when it was set&lt;br /&gt;
*[[Raw_353|353]] - containing the names on the channel (like when using [[Names|/names]])&lt;br /&gt;
*[[Raw_366|366]] - containing the message that the list of names has ended&lt;br /&gt;
*[[Raw_324|324]] - containing the modes that are currently set (like when using [[Mode|/mode]])&lt;br /&gt;
*[[Raw_329|329]] - containing the creation date of the channel&lt;br /&gt;
&lt;br /&gt;
If you e.g. want to echo the creation date of the channel to your status window, you would have to use:&lt;br /&gt;
 ; raw 329 returns: &amp;lt;yournick&amp;gt; &amp;lt;#channel&amp;gt; &amp;lt;creation time in unix format&amp;gt;&lt;br /&gt;
 raw 329:*: {&lt;br /&gt;
  [[echo]] -a $2 was created at: [[$asctime]]($3)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to halt mIRC&#039;s default output in connection with a raw-event, you can use [[Haltdef|/haltdef]]. For example:&lt;br /&gt;
 raw 332:*: {&lt;br /&gt;
  haltdef&lt;br /&gt;
 }&lt;br /&gt;
This example would make mIRC not show the topic of a channel you have joined.&lt;br /&gt;
&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6210</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6210"/>
		<updated>2017-04-30T19:58:45Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Agents}}&lt;br /&gt;
&lt;br /&gt;
== Agents ==&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DDE ==&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mIRC Help ==&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script Archives ==&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Basic IRC commands ==&lt;br /&gt;
{{Category:Basic IRC commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Basic IRC commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Oper commands ==&lt;br /&gt;
{{Category:Oper commands}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Oper commands&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Quakenet ==&lt;br /&gt;
{{Category:Quakenet}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Quakenet&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Raws ==&lt;br /&gt;
{{Category:Raws}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Raws&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6209</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6209"/>
		<updated>2017-04-30T19:49:14Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Agents}}&lt;br /&gt;
&lt;br /&gt;
== Agents ==&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DDE ==&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mIRC Help ==&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script Archives ==&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1 style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6208</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6208"/>
		<updated>2017-04-30T19:20:27Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Agents ==&lt;br /&gt;
{{Category:Agents}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1&amp;gt;Agents&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DDE ==&lt;br /&gt;
{{Category:DDE}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1&amp;gt;DDE&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mIRC Help ==&lt;br /&gt;
{{Category:MIRC Help}}&lt;br /&gt;
&amp;lt;categorytree mode=categories depth=1&amp;gt;MIRC Help&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script Archives ==&lt;br /&gt;
{{Category:Script Archive}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1&amp;gt;Script Archive&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
{{Category:Tutorials}}&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=1&amp;gt;Tutorials&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Template:CatList&amp;diff=6207</id>
		<title>Template:CatList</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Template:CatList&amp;diff=6207"/>
		<updated>2017-04-30T18:42:51Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Template:CatList&amp;diff=6205</id>
		<title>Template:CatList</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Template:CatList&amp;diff=6205"/>
		<updated>2017-04-30T18:35:35Z</updated>

		<summary type="html">&lt;p&gt;Cail: Adding a test template for listing categories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ambox&lt;br /&gt;
| text = This is a box used in articles.&lt;br /&gt;
}}{{category handler&lt;br /&gt;
| [[Category:Somecat]]&lt;br /&gt;
| nocat = {{{nocat|}}}   &amp;lt;!--So &amp;quot;nocat=true/false&amp;quot; works--&amp;gt;&lt;br /&gt;
}}&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!--Add categories and interwikis to the /doc subpage--&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6204</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6204"/>
		<updated>2017-04-30T17:47:25Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6203</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6203"/>
		<updated>2017-04-30T17:47:05Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cat|MIRC}}&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6202</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6202"/>
		<updated>2017-04-30T17:46:53Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Commons cat|MIRC}}&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6201</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6201"/>
		<updated>2017-04-30T17:45:52Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:MIRC]]&lt;br /&gt;
[[Category:IRC]]&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6200</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6200"/>
		<updated>2017-04-30T17:29:57Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6199</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6199"/>
		<updated>2017-04-30T17:29:49Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Category:Contents]&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6198</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6198"/>
		<updated>2017-04-30T17:29:18Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Contents]]&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6197</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6197"/>
		<updated>2017-04-28T20:58:18Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages depth=3&amp;gt;MIRC&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6196</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6196"/>
		<updated>2017-04-28T20:57:39Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages depth=3&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=MediaWiki:Common.js&amp;diff=6195</id>
		<title>MediaWiki:Common.js</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=MediaWiki:Common.js&amp;diff=6195"/>
		<updated>2017-04-28T20:56:40Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* Any JavaScript here will be loaded for all users on every page load. */&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6194</id>
		<title>Speccats</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=Speccats&amp;diff=6194"/>
		<updated>2017-04-28T20:55:44Z</updated>

		<summary type="html">&lt;p&gt;Cail: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree mode=pages&amp;gt;IRC&amp;lt;/categorytree&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
	<entry>
		<id>https://script.quakenet.org/wiki/index.php?title=MediaWiki:Common.js&amp;diff=6193</id>
		<title>MediaWiki:Common.js</title>
		<link rel="alternate" type="text/html" href="https://script.quakenet.org/wiki/index.php?title=MediaWiki:Common.js&amp;diff=6193"/>
		<updated>2017-04-28T20:54:39Z</updated>

		<summary type="html">&lt;p&gt;Cail: Created page with &amp;quot;/* Any JavaScript here will be loaded for all users on every page load. */  $(&amp;#039;.CategoryTreeToggle&amp;#039;).click();&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* Any JavaScript here will be loaded for all users on every page load. */&lt;br /&gt;
&lt;br /&gt;
$(&#039;.CategoryTreeToggle&#039;).click();&lt;/div&gt;</summary>
		<author><name>Cail</name></author>
	</entry>
</feed>