SReject

Y U Jelly

Mar 5th, 2011
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 17.20 KB | None | 0 0
  1. /*
  2.   After Loading the script:
  3.  
  4.   To play: /tetris
  5.  
  6.   Move:
  7.     Left:        a/left
  8.     Right:       d/right
  9.     SoftDrop:    s/down
  10.  
  11.     Rotate:        w/up
  12.     Hardrop:       spacebar
  13.  
  14.     Click to pause/resume
  15.     Click to restart at gameover
  16. */
  17.  
  18. alias Tetris {
  19.   Tetris:Cleanup
  20.   window -Bdfhnpl20 +d @Tetris:Buffer -1 -1 376 454
  21.   if (!$isfile($scriptdirTetris.bmp)) { Tetris:MakeSprites }
  22.   drawpic -c @Tetris:Buffer 0 0 $qt($scriptdirTetris.bmp)
  23.   var %x 1 | while (%x < 26) { aline -l @Tetris:Buffer 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | inc %x }
  24.   window -nBdfpk0C +d @Tetris -1 -1 360 454
  25.   set %Tetris:State Play
  26.   Tetris:Shape
  27.   window -a @Tetris
  28.   Tetris:Play
  29. }
  30.  
  31.  
  32. alias -l Tetris:Cleanup { .TimerTetris Off | unset %Tetris:* | close -@ @Tetris* }
  33. alias -l Tetris:Shape {
  34.   :loop
  35.   set -e %Tetris:Shape %Tetris:nShape
  36.   if ($r(1,7) == 1) { set %Tetris:nShape r 1 0 8 -1 8 -2 8 -3 8 }
  37.   if ($v1 == 2) { set %Tetris:nShape g 1 0 8 0 7 -1 7 -1 8 }
  38.   if ($v1 == 3) { set %Tetris:nShape b 1 0 8 0 7 -1 8 -1 9 }
  39.   if ($v1 == 4) { set %Tetris:nShape o 1 0 8 0 9 -1 7 -1 8 }
  40.   if ($v1 == 5) { set %Tetris:nShape y 1 0 8 -1 8 0 9 0 7 }
  41.   if ($v1 == 6) { set %Tetris:nShape p 1 0 8 -1 8 -2 8 -2 7 }
  42.   if ($v1 == 7) { set %Tetris:nShape t 1 0 8 -1 8 -2 8 -2 9 }
  43.   if (!%Tetris:Shape) { set -e %Tetris:Shape %Tetris:nShape | goto loop }
  44.   Tetris:Land
  45. }
  46. alias -l Tetris:Land {
  47.   tokenize 32 %Tetris:Shape
  48.   while ($3 < 25) && (!$gettok($line(@Tetris:Buffer,$calc($3 +1),1),$4,32) && !$gettok($line(@Tetris:Buffer,$calc($5 +1),1),$6,32) && !$gettok($line(@Tetris:Buffer,$calc($7 +1),1),$8,32) && !$gettok($line(@Tetris:Buffer,$calc($9 +1),1),$10,32)) {
  49.     tokenize 32 $1-2 $calc($3 + 1) $4 $calc($5 +1) $6 $calc($7 + 1) $8 $calc($9 + 1) $10
  50.   }
  51.   set %Tetris:Land $1-
  52. }
  53. alias -l Tetris:Redraw {
  54.   if (!$window(@Tetris) || !$window(@Tetris:Buffer)) { Tetris:Cleanup }
  55.   drawcopy -n @Tetris:Buffer 0 0 360 454 @Tetris 0 0
  56.   var %x = 25, %c
  57.   while ((%x && $line(@Tetris:Buffer,%x,1) != 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) {
  58.     tokenize 32 $v1
  59.     var %y = $calc((%x -1) * 17 + 23)
  60.     if ($1) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$1) - 1)) 16 16 @Tetris 7 %y }
  61.     if ($2) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$2) - 1)) 16 16 @Tetris 24 %y }
  62.     if ($3) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$3) - 1)) 16 16 @Tetris 41 %y }
  63.     if ($4) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$4) - 1)) 16 16 @Tetris 58 %y }
  64.     if ($5) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$5) - 1)) 16 16 @Tetris 75 %y }
  65.     if ($6) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$6) - 1)) 16 16 @Tetris 92 %y }
  66.     if ($7) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$7) - 1)) 16 16 @Tetris 109 %y }
  67.     if ($8) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$8) - 1)) 16 16 @Tetris 126 %y }
  68.     if ($9) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$9) - 1)) 16 16 @Tetris 143 %y }
  69.     if ($10) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$10) - 1)) 16 16 @Tetris 160 %y }
  70.     if ($11) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$11) - 1)) 16 16 @Tetris 177 %y }
  71.     if ($12) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$12) - 1)) 16 16 @Tetris 194 %y }
  72.     if ($13) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$13) - 1)) 16 16 @Tetris 211 %y }
  73.     if ($14) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$14) - 1)) 16 16 @Tetris 228 %y }
  74.     if ($15) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$15) - 1)) 16 16 @Tetris 245 %y }
  75.     dec %x  
  76.   }
  77.   tokenize 32 %Tetris:nShape
  78.   %c = $calc(16 * ($pos(rgboypt,$1) - 1))
  79.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($4 -8)*17+294) $calc(($3 +3)*17+371)
  80.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($6 -8)*17+294) $calc(($5 +3)*17+371)
  81.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($8 -8)*17+294) $calc(($7 +3)*17+371)
  82.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($10 -8)*17+294) $calc(($9 +3)*17+371)
  83.   var %lv = $floor($calc($iif(%Tetris:Lines,$v1,0) / 10))
  84.   var %ln = $iif($calc(10 - %Tetris:Lines % 10),$v1,10)
  85.   var %sc = $iif(%Tetris:Score,$v1,0)  
  86.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%lv,Tahoma,12,1)) 50 %lv
  87.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%ln,Tahoma,12,1)) 80 %ln
  88.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%sc,Tahoma,12,1)) 110 %sc
  89.   if (%Tetris:Land && !%TetrisHideGhost) {
  90.     tokenize 32 %Tetris:Land
  91.     var %c = $gettok(255 65280 16711680 33023 65535 16711935 16776960,$pos(rgboypt,$1),32)      
  92.     if ($3 > 0) drawrect -rn @Tetris %c 2 $calc($4 *17 - 10) $calc($3 *17 + 6) 16 16
  93.     if ($5 > 0) drawrect -rn @Tetris %c 2 $calc($6 *17 - 10) $calc($5 *17 + 6) 16 16
  94.     if ($7 > 0) drawrect -rn @Tetris %c 2 $calc($8 *17 - 10) $calc($7 *17 + 6) 16 16
  95.     if ($9 > 0) drawrect -rn @Tetris %c 2 $calc($10 *17 - 10) $calc($9 *17 + 6) 16 16
  96.   }
  97.   tokenize 32 %Tetris:Shape
  98.   %c = $calc(16 * ($pos(rgboypt,$1) - 1))
  99.   if ($3 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $4 * 17) $calc($3 * 17 + 6)
  100.   if ($5 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $6 * 17) $calc($5 * 17 + 6)
  101.   if ($7 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $8 * 17) $calc($7 * 17 + 6)
  102.   if ($9 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $10 * 17) $calc($9 * 17 + 6)
  103.   if (%Tetris:State == GAMEOVER) || (%Tetris:State == PAUSED) {
  104.     var %m = $v1
  105.     drawrect -rfn @Tetris $rgb(96,96,96) 1 34 185 200 100
  106.     drawrect -rn @Tetris $rgb(192,192,192) 1 34 185 200 100
  107.     drawtext -rno @Tetris 0 "Courier New" 40 $calc(34 + (200 - $width(%m,Courier New,40,1)) /2) $calc(185 + (100 - $height(%m,Courier New,40)) / 2) %m
  108.   }
  109.   drawdot @Tetris
  110. }
  111. alias -l Tetris:MakeSprites {
  112.   if ($isfile($scriptdirTetris.bmp)) { .remove $qt($scriptdirTetris.bmp) }
  113.   var %x = 1, %c = 255,000,000 000,255,000 000,000,255 255,128,000 255,255,000 255,000,255 000,255,255
  114.   if ($window(@Tetris:MakeSprites)) { window -c $v1 }
  115.   window -Bdfhnp +d @Tetris:MakeSprites -1 -1 376 454
  116.   drawrect -nfr @Tetris:MakeSprites 0 1 0 0 360 454
  117.   drawrect -nfr @Tetris:MakeSprites $rgb(128,128,128) 1 1 1 358 15
  118.   drawrect -nrf @Tetris:MakeSprites $rgb(32,32,32) 1 7 23 254 424 268 39 85 90
  119.   drawrect -nfr @Tetris:MakeSprites $rgb(96,96,96) 1 268 346 85 15 268 23 85 15
  120.   drawrect -nr @Tetris:MakeSprites $rgb(192,192,192) 1 0 0 360 454 6 22 256 426 267 345 87 103 267 22 86 108
  121.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 0 16 360 16
  122.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 267 361 353 361
  123.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 267 38 353 38
  124.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 5 12 5 3 14 3 13 4 6 4 6 11 5 12
  125.   drawline -nr @Tetris:MakeSprites $rgb(64,64,64) 1 15 4 15 13 6 13 7 12 14 12 14 5 15 4
  126.   drawrect -nr @Tetris:MakeSprites $rgb(192,192,192) 1 55 2 10 2 55 12 6 2 57 4 2 8 63 4 2 2 62 8 2 6 64 12 2 2 67 2 6 2 67 12 6 2 69 4 2 8 75 4 2 2 83 4 2 2 75 10 2 2 83 10 2 2 75 2 10 2 75 12 10 2 331 10 8 2 19 2 2 4 27 2 2 4 21 2 6 2 23 5 2 7 21 12 6 2 31 2 10 2 31 12 10 2 33 4 2 8 36 7 2 2 39 4 2 2 39 10 2 2 43 2 2 4 51 2 2 4 45 2 6 2 47 5 2 7 45 12 6 2
  127.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 63 5 58 10 58 11 64 5 63 5
  128.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 75 5 83 10 84 10 76 5 75 5
  129.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 345 5 351 11 352 11 346 5 345 5
  130.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 351 5 345 11 346 11 352 5 351 5
  131.   while (%x < 8) {
  132.     tokenize 44 $gettok(%c,%x,32)
  133.     var %nY = $calc(2 + 16 * (%x - 1)), %nY-2 = $calc(%nY -2), %nY-1 = $calc(%nY -1), %nY+1 = $calc(%nY +11), %nY+2 = $calc(%nY +12), %nY+3 = $calc(%nY +13), %tc = $Tetris:Color($1,$2,$3,1.75), %bc = $Tetris:Color($1,$2,$3,.50), %sc = $Tetris:Color($1,$2,$3,.75)
  134.     drawline -rn @Tetris:MakeSprites %tc 1 362 %nY-1 373 %nY-1 374 %nY-2 361 %nY-2 362 %nY-1
  135.     drawline -rn @Tetris:MakeSprites %bc 1 362 %nY+2 373 %nY+2 374 %nY+3 361 %nY+3 362 %nY+2
  136.     drawline -rn @Tetris:MakeSprites %sc 1 361 %nY 361 %nY+1 360 %nY+2 360 %nY-1 361 %nY
  137.     drawline -rn @Tetris:MakeSprites %sc 1 374 %nY 374 %nY+1 375 %nY+2 375 %nY-1 374 %nY
  138.     drawdot -rn @Tetris:MakeSprites $Tetris:Color(%tc,%sc) 1 360 %nY-2 361 %nY-1 374 %nY-1 375 %nY-2
  139.     drawdot -rn @Tetris:MakeSprites $Tetris:Color(%bc,%sc) 1 360 %nY+3 361 %nY+2 374 %nY+2 375 %nY+3
  140.     drawrect -fnr @Tetris:MakeSprites $rgb($1,$2,$3) 1 362 %nY 12 12
  141.     inc %x
  142.   }
  143.   %x = 7 | while (%x < 41) { drawdot -rn @Tetris:MakeSprites 4210752 1 %x $iif($calc(%x % 2),56,39) | inc %x }
  144.   %x = 23 | while (%x < 57) { drawdot -rn @Tetris:MakeSprites 4210752 1 $iif($calc(%x % 2),40,23) %x | inc %x }
  145.   %x = 1 | while (%x < 12) { drawcopy -n @Tetris:MakeSprites 7 23 34 $iif(%x == 1,34,50) @Tetris:MakeSprites 7 $calc(23 + 34 * %x) | inc %x }
  146.   %x = 1 | while (%x < 7) { drawcopy -n @Tetris:MakeSprites 7 23 $iif(%x == 1,34,50) 424 @Tetris:MakeSprites $calc(7 + 34 * %x) 23 | inc %x }
  147.   drawcopy @Tetris:MakeSprites 15 31 85 85 @Tetris:MakeSprites 268 362
  148.   drawtext -onr @Tetris:MakeSprites $rgb(192,192,192) Tahoma 12 271 23 Stats
  149.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 39 Level:
  150.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 69 Lines Left:
  151.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 99 Score:
  152.   drawtext -onr @Tetris:MakeSprites $rgb(192,192,192) Tahoma 12 271 346 Next
  153.   drawdot @Tetris:MakeSprites
  154.   drawsave @Tetris:MakeSprites $qt($scriptdirTetris.bmp)
  155.   window -c @Tetris:MakeSprites
  156.   :error
  157.   if ($window(@Tetris:MakeSprites)) { window -c @Tetris:MakeSprites }
  158. }
  159.  
  160.  
  161.  
  162.  
  163. on *:CLOSE:@Tetris,@Tetris:{ Tetris:Cleanup }
  164. alias Tetris:Play {
  165.   if ($window(@Tetris) && $window(@Tetris:Buffer)) {
  166.     ;if (!$appactive) || ($window(@Tetris) != $active) { set %Tetris:State PAUSED }
  167.     if (%Tetris:State == Play) {
  168.       :reCheck
  169.       tokenize 32 %Tetris:Shape
  170.       var %s, %sL, %sP, %nL, %x = 3, %ok, %nShape $1-2
  171.       while (%x < 11) {
  172.         var %sL = $(,$ $+ %x), %sP = $(,$ $+ $calc(%x +1)), %nL = $calc(%sL +1)
  173.         if (%sL == 0) && ($gettok($line(@Tetris:Buffer,1,1),%sP,32) != 0) { set %Tetris:State GAMEOVER | break }
  174.         elseif (%sL == 25) || (%sL isnum 0-24 && $gettok($line(@Tetris:Buffer,%nL,1),%sP,32) != 0) { break }
  175.         else { %nShape = %nShape %nL %sP }
  176.         inc %x 2
  177.       }
  178.       if (%Tetris:State == PLAY) {
  179.         if ($numtok(%nShape,32) != 10) || ($v1 == 10 && 25 isin %nShape) {
  180.           if ($numtok(%nShape,32) == 10 && 25 isin %nShape) { tokenize 32 $v2 }
  181.           if ($3 < 1 || $4 < 1 || $7 < 1 || $9 < 1) { %Tetris:State = GAMEOVER | goto end }
  182.           rline -l @Tetris:Buffer $3 $puttok($line(@Tetris:Buffer,$3,1),$1,$4,32)
  183.           rline -l @Tetris:Buffer $5 $puttok($line(@Tetris:Buffer,$5,1),$1,$6,32)
  184.           rline -l @Tetris:Buffer $7 $puttok($line(@Tetris:Buffer,$7,1),$1,$8,32)
  185.           rline -l @Tetris:Buffer $9 $puttok($line(@Tetris:Buffer,$9,1),$1,$10,32)
  186.           var %lns
  187.           while ($fline(@Tetris:Buffer,/^([^0](?:\x20|$)){15}$/,1,3)) {
  188.             dline -l @Tetris:Buffer $v1
  189.             iline -l @Tetris:Buffer 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  190.             inc %lns
  191.           }
  192.           if (%lns) {
  193.             inc -e %Tetris:Lines %lns
  194.             inc -e %Tetris:Score $floor($calc(($floor($calc(%Tetris:Lines / 10)) +1) *10 * (1.2^ %lns)))
  195.           }
  196.           Tetris:Shape
  197.           goto reCheck
  198.         }
  199.         else {  
  200.           set %Tetris:Shape %nShape
  201.           tokenize 32 %nShape
  202.           if ($3 < 1 && $5 < 1 && $7 < 1 && $8 < 1) { goto reCheck }
  203.         }
  204.       }
  205.     }
  206.     :end
  207.     Tetris:Redraw
  208.     .timerTetris -h 1 $iif($iif(%Tetris:State != Play,0,$floor($calc(%Tetris:Lines / 10))) > 19,50,$floor($calc(50 + 1.435 ^(20 - $v1)))) Tetris:Play
  209.   }
  210.   else {
  211.     Tetris:Cleanup
  212.   }
  213. }
  214.  
  215.  
  216.  
  217.  
  218. Menu @Tetris {
  219.   $iif(!%TetrisHideGhost,$style(1)) Show Ghosts:{ set %TetrisHideGhost $iif(%TetrisHideGhost,$false,$true) | Tetris:Redraw }
  220.   Restart:{ Tetris }
  221.   -
  222.   Close:{ Tetris:Cleanup }
  223. }
  224. Menu @Tetris {
  225.   sclick:{
  226.     if (%Tetris:State == PAUSED) {
  227.       set -e %Tetris:State PLAY
  228.       Tetris:Play
  229.     }
  230.     elseif ($inrect($mouse.x,$Mouse.y,329,3,12,11)) { set %Tetris:State PAUSED | window -n @Tetris }
  231.     elseif ($inrect($mouse.x,$mouse.y,344,3,12,11)) { Tetris:Cleanup }
  232.     elseif (%Tetris:State == PLAY) { set -e %Tetris:State PAUSED | Tetris:Redraw }
  233.     elseif (%Tetris:State == GAMEOVER) { Tetris }
  234.   }
  235. }
  236.  
  237.  
  238. on *:KEYDOWN:@Tetris:*:{
  239.   if (!$window(@Tetris:Buffer)) { Tetris:Cleanup }
  240.   elseif (%Tetris:State == GAMEOVER) { Tetris }
  241.   elseif (%Tetris:State == PAUSED) { set -e %Tetris:State PLAY | Tetris:Redraw }
  242.   elseif (%Tetris:State == PLAY) {
  243.     if ($keyval == 32) {
  244.       tokenize 32 %Tetris:Land
  245.       set -e %Tetris:Shape $1-
  246.       Tetris:Play
  247.     }
  248.     elseif ($keyval == 40 || $keyval == 100) && (%Tetris:Shape != %Tetris:Land) {
  249.       tokenize 32 $v1
  250.       set %Tetris:Shape $1-2 $calc($3 +1) $4 $calc($5 + 1) $6 $calc($7 +1) $8 $calc($9 +1) $10
  251.       Tetris:Redraw
  252.     }
  253.     elseif ($istok(37 39 97 100,$Keyval,32)) {
  254.       tokenize 32 %Tetris:Shape
  255.       var %n = $iif($keyval isin 3797,-,+), %n1 = $calc($4 %n 1), %n2 = $calc($6 %n 1), %n3 = $calc($8 %n 1), %n4 = $calc($10 %n 1)
  256.       if (%n1 !isnum 1-15 || %n2 !isnum 1-15 || %n3 !isnum 1-15 || %n4 !isnum 1-15) { return }
  257.       if ($gettok($line(@Tetris:Buffer,$3,1),%n1,32)) { return }
  258.       if ($gettok($line(@Tetris:Buffer,$5,1),%n2,32)) { return }
  259.       if ($gettok($line(@Tetris:Buffer,$7,1),%n3,32)) { return }
  260.       if ($gettok($line(@Tetris:Buffer,$9,1),%n4,32)) { return }
  261.       set %Tetris:Shape $1-3 %n1 $5 %n2 $7 %n3 $9 %n4
  262.       Tetris:Land
  263.       Tetris:Redraw
  264.     }
  265.     elseif ($keyval == 38 || $keyval == 119) {
  266.       tokenize 32 %Tetris:Shape
  267.       var %sL = $3
  268.       var %sP = $4
  269.       var %nShape
  270.       if (!$regex($1,/^[rboypt]$/)) { return }
  271.       elseif ($1 == r) {
  272.         if ($2 == 1) && ($tetris:Check(%sL %sP  %sL $calc(%sP +1) %sL $calc(%sP +2) %sL $calc(%sP -1))) { %nShape = $1 2 $v1 }
  273.         elseif ($2 == 2) && ($tetris:Check(%sL %sP $calc(%sL -1) %sP $calc(%sL -2) %sP $calc(%sL -3) %sP)) { %nShape = $1 1 $v1 }
  274.         else { return }
  275.       }
  276.       elseif ($1 == b) {
  277.         if ($2 == 1) && ($tetris:Check(%sL %sP $calc(%sL -1) %sp $calc(%sL -1) $calc(%sp -1) $calc(%sL -2) $calc(%sP -1))) { %nShape = $1 2 $v1 }
  278.         elseif ($2 == 2) && ($tetris:Check(%sL %sp %sL $calc(%sP -1) $calc(%sL -1) %sp $calc(%sL -1) $calc(%sp +1))) { %nShape = $1 1 $v1 }
  279.         else { return }
  280.       }
  281.       elseif ($1 == o) {
  282.         if ($2 == 1) && ($tetris:Check(%sL %sP, $calc(%sL -1) %sp,$calc(%sL -1) $calc(%sp +1), $calc(%sL -2) $calc(%sP +1))) { %nShape = $1 2 $v1 }
  283.         elseif ($2 == 2) && ($tetris:Check( %sL %sP, %sL $calc(%sP +1), $calc(%sL -1) %sp, $calc(%sL -1) $calc(%sp -1))) { %nShape = $1 1 $v1 }
  284.         else { return }
  285.       }
  286.       elseif ($1 == y) {
  287.         if ($2 == 1) && ($Tetris:Check($calc(%sL -2) %sP $calc(%sL -1) $calc(%sP +1))) { %nShape = $1 2 $3-6 $v1 }
  288.         elseif ($2 == 2) && ($Tetris:Check($calc(%sL -1) $calc(%sP -1) $calc(%sL -1) $calc(%sp +1))) { %nShape = $1 3 $3-6 $v1 }
  289.         elseif ($2 == 3) && ($Tetris:Check($calc(%sL -2) %sp $calc(%sL -1) $calc(%sp -1))) { %nShape = $1 4 $3-6 $v1 }
  290.         elseif ($2 == 4) && ($tetris:Check(%sl $calc(%sP -1) %sL $calc(%sP +1))) { %nShape = $1 1 $3-6 $v1 }
  291.         else { return }
  292.       }
  293.       elseif ($1 == p) {
  294.         if ($2 == 1) && ($Tetris:Check(%sL $calc(%sP -1) %sL $calc(%sP +1) $calc(%sL -1) $calc(%sP +1))) { %nShape = $1 2 $3-4 $v1 }
  295.         elseif ($2 == 2) && ($Tetris:Check(%sL $calc(%sp +1) $calc(%sL -1) %sp $calc(%sL -2) %sp)) { %nShape = $1 3 $3-4 $v1 }
  296.         elseif ($2 == 3) && ($Tetris:Check(%sL $calc(%sp -1) $calc(%sl -1) $calc(%sp -1) $calc(%sL -1) %sp,$calc(%sL -1) $calc(%sP +1))) { %nShape = $1 4 $v1 }
  297.         elseif ($2 == 4) && ($Tetris:Check(%sL $calc(%sp +1) $calc(%sL -1) $calc(%sp +1) $calc(%sL -2) $calc(%sP +1)  $calc(%sL -2) %sP)) { %nShape = $1 1 $v1 }
  298.         else { return }
  299.       }
  300.       elseif ($1 == t) {
  301.         if ($2 == 1) && ($Tetris:Check(%sL $calc(%sP +1) $calc(%sL -1) $calc(%sP +1) $calc(%sL -1) %sp $calc(%sL -1) $calc(%sP -1))) { %nShape = $1 2 $v1 }
  302.         elseif ($2 == 2) && ($Tetris:Check(%sL $calc(%sp -1) %sL $calc(%sp -2) $calc(%sL -1) $calc(%sP -1) $calc(%sL -2) $calc(%sP -1))) { %nShape = $1 3 $v1 }
  303.         elseif ($2 == 3) && ($Tetris:Check(%sL $calc(%sP +1) %sL $calc(%sP -1) $calc(%sl -1) $calc(%sP -1))) { %nShape = $1 4 $3-4 $v1 }
  304.         elseif ($2 == 4) && ($Tetris:Check($calc(%sL -1) %sp $calc(%sL -2) %sp  $calc(%sL -2) $calc(%sP +1))) { %nShape = $1 1 $3-4 $v1 }
  305.         else { return }
  306.       }
  307.       set %Tetris:Shape %nShape
  308.       Tetris:Land
  309.       Tetris:Redraw
  310.     }
  311.   }
  312. }
  313.  
  314. alias -l Tetris:Check {
  315.   tokenize 32 $1-
  316.   var %x = 1, %r
  317.   while (%x < $0) {
  318.     var %sL = $(,$ $+ %x)
  319.     var %sP = $(,$ $+ $calc(%x +1))
  320.     if (%sL > 25) || (%sP !isnum 1-15) || ($gettok($line(@Tetris:Buffer,%sL,1),%sP,32)) {
  321.       return
  322.     }
  323.     %r = %r %sL %sP
  324.     inc %x 2
  325.   }
  326.   return %r
  327. }
Add Comment
Please, Sign In to add comment