SReject

like this?

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