From 3d17957234095520d473a96ae79bae3d897adcc5 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sat, 14 Nov 2020 23:50:55 -0500 Subject: [PATCH] Fixed Tetra-X anti-stall --- tetris/rulesets/tetra.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tetris/rulesets/tetra.lua b/tetris/rulesets/tetra.lua index 25ebe8f..c72ace4 100644 --- a/tetris/rulesets/tetra.lua +++ b/tetris/rulesets/tetra.lua @@ -86,8 +86,21 @@ function Tetra:attemptWallkicks(piece, new_piece, rot_dir, grid) end +function Tetra:checkNewLow(piece) + for _, block in pairs(piece:getBlockOffsets()) do + local y = piece.position.y + block.y + if y > piece.lowest_y then + piece.lock_delay = 0 + piece.lowest_y = y + end + end +end + +function Tetra:onPieceCreate(piece) piece.lowest_y = -math.huge end +function Tetra:onPieceDrop(piece) self:checkNewLow(piece) end function Tetra:onPieceMove() end function Tetra:onPieceRotate() end function Tetra:get180RotationValue() return 2 end return Tetra +