Advertisement
zigwin

#tetris

Jul 20th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.15 KB | None | 0 0
  1. do local _,name = pcall(nil) admin = string.match(name, "(.-)%.") end -- Игрок, запустивший скрипт
  2.  
  3. --[[
  4.  
  5. Controls :
  6. Up - Rotate
  7. Left - Move left
  8. Right - Move right
  9. Down - Move down
  10.  
  11. Commands :
  12. !pause or !p - pauses / unpauses game
  13. !join - join que
  14. !cancel - leave que
  15. --]]
  16. -- player = "Name#Tag" or "auto" else wait for queue
  17. local player = "queue"
  18. -- If true game will end within 100th piece placed
  19. local endlessGame = false
  20. -- "ru" or "en" else auto
  21. local language = tfm.get.room.playerList[admin].community
  22.  
  23. local color = {
  24.     static1 = 0xB3FAFF,
  25.     static2 = 0xB3FAFF,
  26.     dynamic1 = 0x39EDB5,
  27.     dynamic2 = 0x39EDB5,
  28.     walls1 = 0xD8D8D8,
  29.     walls2 = 0xD8D8D8,
  30. }
  31.  
  32. text = {
  33.     ru = {
  34.         join = "Присоединиться",
  35.         cancel = "Отмена",
  36.         queue = "Очередь",
  37.         leaderboard = "Рекорды",
  38.     },
  39.     en = {
  40.         join = "Join",
  41.         cancel = "Cancel",
  42.         queue = "Queue",
  43.         leaderboard = "Leaderboard",
  44.     }
  45. }
  46.  
  47. if not text[language] then
  48.     language = "en"
  49. end
  50.  
  51. -- Offset for tetris grid
  52. local _x, _y = 260, 10
  53.  
  54.  
  55. -- Queue, leaderboard
  56. local playerData, queue, leaderboard = {}, {}, {}
  57. -- 1 player
  58. if player == "auto" then
  59.     player = admin
  60. end
  61.  
  62. local Grid, pieceList, sum, currentPiece, availablePieces, isDown
  63. local pieceX, pieceY, rotation, previousPieceX, previousRotation
  64. local score
  65.  
  66. -- reservedPiece
  67. local pieceData = {
  68.     [1] = {
  69.         -- I
  70.         --[[`   `   `   `
  71.             [ ][ ][ ][ ]
  72.             [x][o][x][x]
  73.             [ ][ ][ ][ ]
  74.             [ ][ ][ ][ ]
  75.            
  76.             [ ][ ][x][ ]
  77.             [ ][ ][x][ ]
  78.             [ ][ ][x][ ]
  79.             [ ][ ][x][ ]
  80.  
  81.             [ ][ ][ ][ ]
  82.             [ ][ ][ ][ ]
  83.             [x][x][x][x]
  84.             [ ][ ][ ][ ]
  85.  
  86.             [ ][x][ ][ ]
  87.             [ ][x][ ][ ]
  88.             [ ][x][ ][ ]
  89.             [ ][x][ ][ ]
  90.         --]]
  91.         [1] = {
  92.             {1,2},
  93.             {2,2},
  94.             {3,2},
  95.             {4,2},
  96.         },
  97.         [2] = {
  98.             {3,1},
  99.             {3,2},
  100.             {3,3},
  101.             {3,4},
  102.         },
  103.         [3] = {
  104.             {1,3},
  105.             {2,3},
  106.             {3,3},
  107.             {4,3},
  108.         },
  109.         [4] = {
  110.             {2,1},
  111.             {2,2},
  112.             {2,3},
  113.             {2,4},
  114.         }
  115.     },
  116.  
  117.     [2] = {
  118.         -- J
  119.         --[[`   `   `   `
  120.             [ ][x][ ]
  121.             [ ][o][ ]
  122.             [x][x][ ]
  123.  
  124.             [x][ ][ ]
  125.             [x][o][x]
  126.             [ ][ ][ ]
  127.  
  128.             [ ][x][x]
  129.             [ ][o][ ]
  130.             [ ][x][ ]
  131.  
  132.             [ ][ ][ ]
  133.             [x][o][x]
  134.             [ ][ ][x]
  135.         --]]
  136.         [1] = {
  137.             {2,1},
  138.             {2,2},
  139.             {2,3},
  140.             {1,3},
  141.         },
  142.         [2] = {
  143.             {1,1},
  144.             {1,2},
  145.             {2,2},
  146.             {3,2},
  147.         },
  148.         [3] = {
  149.             {2,1},
  150.             {2,2},
  151.             {2,3},
  152.             {3,1},
  153.         },
  154.         [4] = {
  155.             {3,3},
  156.             {1,2},
  157.             {2,2},
  158.             {3,2},
  159.         }
  160.     },
  161.  
  162.     [3] = {
  163.         -- L
  164.         --[[`   `   `   `
  165.             [ ][x][ ]
  166.             [ ][o][ ]
  167.             [ ][x][x]
  168.  
  169.             [ ][ ][ ]
  170.             [x][o][x]
  171.             [x][ ][ ]
  172.  
  173.             [x][x][ ]
  174.             [ ][o][ ]
  175.             [ ][x][ ]
  176.  
  177.             [ ][ ][x]
  178.             [x][o][x]
  179.             [ ][ ][ ]
  180.         --]]
  181.         [1] = {
  182.             {2,1},
  183.             {2,2},
  184.             {2,3},
  185.             {3,3},
  186.         },
  187.         [2] = {
  188.             {1,3},
  189.             {1,2},
  190.             {2,2},
  191.             {3,2},
  192.         },
  193.         [3] = {
  194.             {2,1},
  195.             {2,2},
  196.             {2,3},
  197.             {1,1},
  198.         },
  199.         [4] = {
  200.             {3,1},
  201.             {1,2},
  202.             {2,2},
  203.             {3,2},
  204.         }
  205.     },
  206.  
  207.     [4] = {
  208.         -- T
  209.         --[[`   `   `   `
  210.             [ ][x][ ]
  211.             [x][o][x]
  212.             [ ][ ][ ]
  213.  
  214.             [ ][x][ ]
  215.             [ ][o][x]
  216.             [ ][x][ ]
  217.  
  218.             [ ][ ][ ]
  219.             [x][o][x]
  220.             [ ][x][ ]
  221.  
  222.             [ ][x][ ]
  223.             [x][o][ ]
  224.             [ ][x][ ]
  225.         --]]
  226.         [1] = {
  227.             {2,2},
  228.             {2,1},
  229.             {1,2},
  230.             {3,2},
  231.         },
  232.         [2] = {
  233.             {2,2},
  234.             {2,1},
  235.             {3,2},
  236.             {2,3},
  237.         },
  238.         [3] = {
  239.             {2,2},
  240.             {2,3},
  241.             {1,2},
  242.             {3,2},
  243.         },
  244.         [4] = {
  245.             {2,2},
  246.             {2,1},
  247.             {1,2},
  248.             {2,3},
  249.         }
  250.     },
  251.  
  252.     [5] = {
  253.         -- S
  254.         --[[`   `   `   `
  255.             [ ][x][x]
  256.             [x][x][ ]
  257.             [ ][ ][ ]
  258.  
  259.             [ ][x][ ]
  260.             [ ][x][x]
  261.             [ ][ ][x]
  262.  
  263.             [ ][ ][ ]
  264.             [ ][x][x]
  265.             [x][x][ ]
  266.  
  267.             [x][ ][ ]
  268.             [x][x][ ]
  269.             [ ][x][ ]
  270.         --]]
  271.         [1] = {
  272.             {2,2},
  273.             {1,2},
  274.             {2,1},
  275.             {3,1},
  276.         },
  277.         [2] = {
  278.             {2,2},
  279.             {2,1},
  280.             {3,2},
  281.             {3,3},
  282.         },
  283.         [3] = {
  284.             {2,2},
  285.             {1,3},
  286.             {2,3},
  287.             {3,2},
  288.         },
  289.         [4] = {
  290.             {2,2},
  291.             {1,1},
  292.             {1,2},
  293.             {2,3},
  294.         }
  295.     },
  296.  
  297.     [6] = {
  298.         -- Z
  299.         --[[`   `   `   `
  300.             [x][x][ ]
  301.             [ ][x][x]
  302.             [ ][ ][ ]
  303.  
  304.             [ ][ ][x]
  305.             [ ][x][x]
  306.             [ ][x][ ]
  307.  
  308.             [ ][ ][ ]
  309.             [x][x][ ]
  310.             [ ][x][x]
  311.  
  312.             [ ][x][ ]
  313.             [x][x][ ]
  314.             [x][ ][ ]
  315.         --]]
  316.         [1] = {
  317.             {2,2},
  318.             {1,1},
  319.             {2,1},
  320.             {3,2},
  321.         },
  322.         [2] = {
  323.             {2,2},
  324.             {2,3},
  325.             {3,1},
  326.             {3,2},
  327.         },
  328.         [3] = {
  329.             {2,2},
  330.             {1,2},
  331.             {2,3},
  332.             {3,3},
  333.         },
  334.         [4] = {
  335.             {2,2},
  336.             {1,2},
  337.             {1,3},
  338.             {2,1},
  339.         }
  340.     },
  341.  
  342.     [7] = {
  343.         -- o
  344.         --[[`   `   `   `
  345.             [x][x]
  346.             [x][x]
  347.         --]]
  348.         [1] = {
  349.             {1,1},
  350.             {1,2},
  351.             {2,1},
  352.             {2,2},
  353.         },
  354.         [2] = {
  355.             {1,1},
  356.             {1,2},
  357.             {2,1},
  358.             {2,2},
  359.         },
  360.         [3] = {
  361.             {1,1},
  362.             {1,2},
  363.             {2,1},
  364.             {2,2},
  365.         },
  366.         [4] = {
  367.             {1,1},
  368.             {1,2},
  369.             {2,1},
  370.             {2,2},
  371.         }
  372.     },
  373. }
  374.  
  375. function initGame()
  376.     -- Init varables
  377.     Grid = {}
  378.     score = 0
  379.     rotation = 1
  380.     do
  381.         local _pieceList = {16, 14, 14, 14, 14, 14, 14}
  382.         local _availablePieces = {true, true, true, true, true, true, true}
  383.         pieceList = _PieceList
  384.         availablePieces = _availablePieces
  385.     end
  386.     sum = 100
  387.  
  388.     -- Clear grid
  389.     for x=1,12 do
  390.         Grid[x] = {}
  391.         for y=1,18 do
  392.             -- 0 - empty
  393.             -- 1 - soild
  394.             -- 2 - dynamic
  395.             Grid[x][y] = {contains = 0, color = ""}
  396.         end
  397.     end
  398.  
  399.     local walls = {
  400.         {1,1}, {2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {9,1}, {10,1}, {11,1}, {12,1},
  401.         {1,2}, {12,2},
  402.         {1,3}, {12,3},
  403.         {1,4}, {12,4},
  404.         {1,5}, {12,5},
  405.         {1,6}, {12,6},
  406.         {1,7}, {12,7},
  407.         {1,8}, {12,8},
  408.         {1,9}, {12,9},
  409.         {1,10}, {12,10},
  410.         {1,11}, {12,11},
  411.         {1,12}, {12,12},
  412.         {1,13}, {12,13},
  413.         {1,14}, {12,14},
  414.         {1,15}, {12,15},
  415.         {1,16}, {12,16},
  416.         {1,17}, {12,17},
  417.         {1,18},{2,18},{3,18},{4,18},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},
  418.     }
  419.  
  420.     for i, v in next, walls do
  421.         local x, y = v[1], v[2]
  422.         Grid[x][y].contains = 1
  423.         ui.addTextArea(-i-100, " ", nil, (x * 20) + _x, (y * 20) + _y, 16, 16, color.walls1, color.walls2)
  424.     end
  425.  
  426.     nextPiece()
  427.     setPiecePos(pieceX, pieceY)
  428.     drawGrid()
  429.     start = true
  430.     for i = 0, 3 do
  431.         system.bindKeyboard(player, i, true, true)
  432.     end
  433. end
  434.  
  435. function refreshGame()
  436.     -- Stop game and clear grid
  437.     start = false
  438.     drawGrid(true)
  439.     for i = 1, 260 do
  440.         ui.removeTextArea(i)
  441.     end
  442.  
  443.     -- Set score + leaderboard
  444.     tfm.exec.setPlayerScore(player, score, true)
  445.     leaderboard[#leaderboard + 1] = {
  446.         playerName = player,
  447.         score = score,
  448.         sum = (100 - sum),
  449.     }
  450.  
  451.     -- Deactivate keyboard and remove from game
  452.     for i = 0, 3 do
  453.         system.bindKeyboard(player, i, true, false)
  454.     end
  455.     playerData[player].isPlaying = false
  456.     drawQueue()
  457.     drawLeaderboard()
  458. end
  459.  
  460. function nextPiece()
  461.     isDown = false
  462.  
  463.     local random
  464.     repeat
  465.         random = math.random(1, 7)
  466.     until availablePieces[random]
  467.  
  468.     if endlessGame and sum == 0 then
  469.             if sum == 0 then
  470.                 print("You won!")
  471.                 print("You got "..score.." score!")
  472.                 print("Placed "..(100 - sum).." pieces!")
  473.                 refreshGame()
  474.             return
  475.         end
  476.  
  477.         pieceList[random] = pieceList[random] - 1
  478.    
  479.         if pieceList[random] == 0 then
  480.             availablePieces[random] = false
  481.         end
  482.     end
  483.  
  484.     currentPiece = random
  485.  
  486.     pieceX = 5
  487.     pieceY = 1
  488.  
  489.     previousPieceX = 5
  490.     previousPieceY = 1
  491.  
  492.     rotation = 1
  493.     previousRotation = 1
  494.  
  495.     sum = sum - 1
  496. end
  497.  
  498. function setPiecePos(x, y)
  499.     -- Remove previous
  500.     for _, pos in next, pieceData[currentPiece][previousRotation] do
  501.         Grid[previousPieceX + pos[1]][previousPieceY + pos[2]].contains = 0
  502.     end
  503.     -- Set Position
  504.     for _, pos in next, pieceData[currentPiece][rotation] do
  505.         Grid[x + pos[1]][y + pos[2]].contains = 2
  506.     end
  507.     previousRotation = rotation
  508.     previousPieceX = pieceX
  509.     previousPieceY = pieceY
  510. end
  511.  
  512. function drawGrid(drawStatic)
  513.     --[[
  514.     id 1 - 99 dynamic cells
  515.     id 100 - 999 static
  516.     --]]
  517.  
  518.     if drawStatic then
  519.         local i = 1
  520.         for x = 2, 11 do
  521.             for y = 2, 17 do
  522.                 if Grid[x][y].contains == 1 then
  523.                     ui.addTextArea(99+i, '', nil, (x * 20) + _x, (y * 20) + _y, 14, 14, color.static1, color.static2)
  524.                     i = i + 1
  525.                 end
  526.             end
  527.         end
  528.     end
  529.  
  530.     for i, value in next, pieceData[currentPiece][rotation] do
  531.         local x, y = value[1]+pieceX, value[2]+pieceY
  532.         ui.addTextArea(i, '', nil, (x * 20) + _x, (y * 20) + _y, 14, 14, color.dynamic1, color.dynamic2)
  533.     end
  534. end
  535.  
  536. --[[    With platforms
  537.  
  538. tfm.exec.addPhysicObject(i, x * 20, y * 20, {
  539.     type = 1,
  540.     width = 20,
  541.     height = 20,
  542.     foreground = true,
  543.     miceCollision = false,
  544.     groundCollision = false,
  545. })
  546.  
  547. --]]
  548.  
  549. function eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
  550.     if not start then
  551.         return
  552.     end
  553.  
  554.     if keyCode == 1 then
  555.         -- Up
  556.         -- Rotate
  557.         local ToData = pieceData[currentPiece][(rotation < 4 and rotation + 1) or 1]
  558.         for _, pos in next, ToData do
  559.             if Grid[pos[1] + pieceX][pos[2] + pieceY].contains == 1 then
  560.                 return
  561.             end
  562.         end
  563.         rotation = (rotation < 4 and rotation + 1) or 1
  564.     elseif keyCode == 0 then
  565.         -- Left
  566.         -- Move
  567.  
  568.         for i, value in next, pieceData[currentPiece][rotation] do
  569.             local x, y = value[1]+pieceX-1, value[2]+pieceY
  570.            
  571.             if Grid[x][y].contains == 1 then
  572.                 return
  573.             end
  574.         end
  575.         pieceX = pieceX - 1
  576.  
  577.     elseif keyCode == 2 then
  578.         -- Right
  579.         -- Move
  580.  
  581.         for i, value in next, pieceData[currentPiece][rotation] do
  582.             local x, y = value[1]+pieceX+1, value[2]+pieceY
  583.            
  584.             if Grid[x][y].contains == 1 then
  585.                 return
  586.             end
  587.         end
  588.         pieceX = pieceX + 1
  589.  
  590.     elseif keyCode == 3 then
  591.         if not isDown then
  592.             isDown = true
  593.             -- Down
  594.             -- Instant plaing
  595.             local yc = 1
  596.  
  597.             --while not( Grid[x][y + yc].contains == 1 or y + yc >= 18 ) do
  598.             while true do
  599.                 for i, value in next, pieceData[currentPiece][rotation] do
  600.                     local x, y = value[1]+pieceX, value[2]+pieceY+yc
  601.                    
  602.                     if Grid[x][y].contains == 1 then
  603.                         pieceY = pieceY + yc - 2
  604.                         return
  605.                     end
  606.                 end
  607.                 yc = yc + 1
  608.             end
  609.         end
  610.     end
  611.     setPiecePos(pieceX, pieceY)
  612.     drawGrid()
  613. end
  614.  
  615. start = false
  616.  
  617. function eventLoop(currentTime, timeRemaining)
  618.     if start then
  619.         -- Check if reached down limit
  620.  
  621.         for x = 1, 12 do
  622.             for y = 1, 18 do
  623.                 local contain = Grid[x][y].contains
  624.  
  625.                 if contain == 2 and Grid[x][y+1].contains == 1 then
  626.                     -- If theres obstacle
  627.                     -- Find dynamic and make it solid
  628.                     for x = 1, 12 do
  629.                         for y = 1, 18 do
  630.                             local contain = Grid[x][y].contains
  631.                             if contain == 2 then
  632.                                 Grid[x][y].contains = 1
  633.                             end
  634.                         end
  635.                     end
  636.  
  637.                     -- Removing line if it full
  638.                     -- Check if it full
  639.  
  640.                     --for y = 17, 3, -1 do
  641.                     local y = 17
  642.  
  643.                     while y > 3 do
  644.                         local i = 0
  645.                         for x = 2, 11 do
  646.                             if Grid[x][y].contains == 1 then
  647.                                 i = i + 1
  648.                             end
  649.                         end
  650.                         -- Removing
  651.                         if i == 10 then
  652.                             for x = 2, 11 do
  653.                                 for y2 = y, 3, -1 do
  654.                                     Grid[x][y2].contains = Grid[x][y2-1].contains
  655.                                     Grid[x][y2].color = Grid[x][y2-1].color
  656.                                 end
  657.                             end
  658.                             score = score + 1
  659.                             for i = 1, 260 do
  660.                                 ui.removeTextArea(i)
  661.                             end
  662.                         else
  663.                             y = y - 1
  664.                             if i == 0 then
  665.                                 y = 2
  666.                             end
  667.                         end
  668.                     end
  669.                     for x = 2, 11 do
  670.                         if Grid[x][2].contains == 1 then
  671.                             print("You lost.")
  672.                             print("You have got "..score.." score!")
  673.                             print("Placed "..(100 - sum).." pieces!")
  674.                             refreshGame()
  675.                             return
  676.                         end
  677.                     end
  678.  
  679.                     nextPiece()
  680.                     setPiecePos(pieceX, pieceY)
  681.                     drawGrid(true)
  682.                     return
  683.                 end
  684.             end
  685.         end
  686.  
  687.         pieceY = pieceY + 1
  688.         setPiecePos(pieceX, pieceY)
  689.         drawGrid()
  690.     elseif #queue >= 1 then
  691.         -- Update que
  692.         player = queue[1]
  693.         table.remove(queue, 1)
  694.  
  695.         playerData[player].inQueue = false
  696.         playerData[player].isPlaying = true
  697.  
  698.         drawQueue()
  699.         -- Start game
  700.         initGame()
  701.     end
  702. end
  703.  
  704. function eventChatCommand(playerName, message)
  705.     if not playerData[playerName].isPlaying then
  706.         -- Queue System
  707.         if message == "join" then
  708.             -- Add
  709.             if not playerData[playerName].inQueue then
  710.                 playerData[playerName].inQueue = true
  711.                 queue[#queue + 1] = playerName
  712.                 print("\n"..playerName.." join queue :"..table.concat(queue, "\n"))
  713.                 drawQueue()
  714.             end
  715.         elseif message == "cancel" then
  716.             -- Remove
  717.             if playerData[playerName].inQueue then
  718.                 playerData[playerName].inQueue = false
  719.                 for index, name in next, queue do
  720.                     if name == playerName then
  721.                         table.remove(queue, index)
  722.                         print("\n"..playerName.." left queue :"..table.concat(queue, "\n"))
  723.                         drawQueue()
  724.                         break
  725.                     end
  726.                 end
  727.             end
  728.         end
  729.     else
  730.         if message == 'pause' or message == 'p' then
  731.             start = not start
  732.         end
  733.     end
  734. end
  735.  
  736. --[[    Leaderboard system      --]]
  737.  
  738. function drawLeaderboard()
  739.     table.sort( leaderboard, function ( a, b )
  740.         return a.score > b.score
  741.     end )
  742.  
  743.     local out, c = {"<b><v><p align='center'>"..text[language].leaderboard.."</p></v></b>\n"}, 2
  744.  
  745.     for place, placeData in next, leaderboard do
  746.         if place == 1 then
  747.             out[c] = "<font color='#FFBF00'>"..place..".</font> "..placeData.playerName.." <v>"..placeData.score.."</v><b>/</b><v>"..placeData.sum.."</v>\n"
  748.         elseif place == 2 then
  749.             out[c] = "<font color='#CACACA'>"..place..".</font> "..placeData.playerName.." <v>"..placeData.score.."</v><b>/</b><v>"..placeData.sum.."</v>\n"
  750.         elseif place == 3 then
  751.             out[c] = "<font color='#C67D18'>"..place..".</font> "..placeData.playerName.." <v>"..placeData.score.."</v><b>/</b><v>"..placeData.sum.."</v>\n"
  752.         else
  753.             out[c] = "<vp>"..place..".</vp> "..placeData.playerName.." <v>"..placeData.score.."</v><b>/</b><v>"..placeData.sum.."</v>\n"
  754.         end
  755.         c = c + 1
  756.     end
  757.  
  758.     ui.addTextArea(1001, table.concat(out), nil, 580, 40, 160, 180, 0x000000, 0x333333, 0.5, true)
  759. end
  760.  
  761. --[[    Queue system    --]]
  762.  
  763. function drawQueue()
  764.     local out, c = {"<b><v><p align='center'>"..text[language].queue.."</p></v></b>\n"}, 2
  765.  
  766.     for index, playerName in next, queue do
  767.         out[c] = (c-1)..". "..playerName.."\n"
  768.         c = c + 1
  769.     end
  770.     for playerName, Data in next, playerData do
  771.         if Data.inQueue then
  772.             out[c] = "\n<a href='event:cancel'><p align='center'><r>["..text[language].cancel.."]</r></p></a>"
  773.             ui.addTextArea(1000, table.concat(out), playerName, 60, 40, 160, 180, 0x000000, 0x333333, 0.5, true)
  774.         elseif not Data.isPlaying then
  775.             out[c] = "\n<a href='event:join'><p align='center'><vp>["..text[language].join.."]</vp></p></a>"
  776.             ui.addTextArea(1000, table.concat(out), playerName, 60, 40, 160, 180, 0x000000, 0x333333, 0.5, true)
  777.         else
  778.             ui.addTextArea(1000, table.concat(out), playerName, 60, 40, 160, 180, 0x000000, 0x333333, 0.5, true)
  779.         end
  780.     end
  781. end
  782.  
  783. function eventTextAreaCallback(textAreaId, playerName, eventName)
  784.     eventChatCommand(playerName, eventName)
  785. end
  786.  
  787. --[[    Init settings, map etc.     --]]
  788.  
  789. tfm.exec.disableAfkDeath(true)
  790. tfm.exec.disableAutoScore(true)
  791. tfm.exec.disableAutoShaman(true)
  792. tfm.exec.disableAutoNewGame(true)
  793. tfm.exec.disableAutoTimeLeft(true)
  794. tfm.exec.disablePhysicalConsumables(true)
  795.  
  796. tfm.exec.newGame([[<C><P /><Z><S><S H="20" P="0,0,0.3,0.2,0,0,0,0" L="800" o="d2c2c2" X="400" N="" Y="390" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" X="400" L="800" o="d2c2c2" H="400" c="4" Y="200" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="ffffff" H="40" X="400" Y="380" T="14" /><S P="0,0,0.3,0.2,0,0,0,0" L="40" o="ffffff" H="400" X="20" N="" Y="200" T="15" /><S P="0,0,0.3,0.2,0,0,0,0" L="40" o="ffffff" H="400" X="779" N="" Y="200" T="15" /></S><D /><O /></Z></C>]])
  797.  
  798. function eventPlayerDied(playerName)
  799.     tfm.exec.respawnPlayer(playerName)
  800. end
  801.  
  802. function eventNewPlayer(playerName, _)
  803.     if not _ then
  804.         -- Draw Walls
  805.         local walls = {
  806.             {1,1}, {2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {9,1}, {10,1}, {11,1}, {12,1},
  807.             {1,2}, {12,2},
  808.             {1,3}, {12,3},
  809.             {1,4}, {12,4},
  810.             {1,5}, {12,5},
  811.             {1,6}, {12,6},
  812.             {1,7}, {12,7},
  813.             {1,8}, {12,8},
  814.             {1,9}, {12,9},
  815.             {1,10}, {12,10},
  816.             {1,11}, {12,11},
  817.             {1,12}, {12,12},
  818.             {1,13}, {12,13},
  819.             {1,14}, {12,14},
  820.             {1,15}, {12,15},
  821.             {1,16}, {12,16},
  822.             {1,17}, {12,17},
  823.             {1,18},{2,18},{3,18},{4,18},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},
  824.         }
  825.         for i, v in next, walls do
  826.             ui.addTextArea(-i-100, " ", playerName, (v[1] * 20) + _x, (v[2] * 20) + _y, 14, 14, color.walls1, color.walls2)
  827.         end
  828.         drawQueue()
  829.         ui.setMapName("<j>#tetris</j> <bl>- Zigwin</bl>")
  830.  
  831.         tfm.exec.respawnPlayer(playerName)
  832.     end
  833.  
  834.     playerData[playerName] = {
  835.         isPlaying = false,
  836.         inQueue = false,
  837.     }
  838. end
  839.  
  840. for playerName in next, tfm.get.room.playerList do
  841.     eventNewPlayer(playerName, true)
  842. end
  843.  
  844. drawQueue()
  845. drawLeaderboard()
  846. ui.setMapName("<j>#tetris</j> <bl>- Zigwin</bl>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement