Fixed IRS triggering transform in TransRS
parent
5ece2994e9
commit
d837b14c53
|
@ -21,28 +21,34 @@ function Trans:attemptRotate(new_inputs, piece, grid, initial)
|
||||||
end
|
end
|
||||||
|
|
||||||
local new_piece = piece:withRelativeRotation(rot_dir)
|
local new_piece = piece:withRelativeRotation(rot_dir)
|
||||||
|
|
||||||
|
if initial then
|
||||||
|
if (grid:canPlacePiece(new_piece)) then
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
piece:setRelativeRotation(rot_dir)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
repeat
|
repeat
|
||||||
new_piece.shape = pieces[math.random(7)]
|
new_piece.shape = pieces[math.random(7)]
|
||||||
until piece.shape ~= new_piece.shape
|
until piece.shape ~= new_piece.shape
|
||||||
|
|
||||||
if (grid:canPlacePiece(new_piece)) then
|
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}
|
||||||
self:onPieceRotate(piece, grid)
|
for _, o in pairs(offsets) do
|
||||||
piece:setRelativeRotation(rot_dir)
|
local kicked_piece = new_piece:withOffset(o)
|
||||||
piece.shape = new_piece.shape
|
if (grid:canPlacePiece(kicked_piece)) then
|
||||||
else
|
self:onPieceRotate(piece, grid)
|
||||||
if not(initial and self.enable_IRS_wallkicks == false) then
|
piece:setRelativeRotation(rot_dir)
|
||||||
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
|
piece:setOffset(o)
|
||||||
self:onPieceRotate(piece, grid)
|
piece.shape = new_piece.shape
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
return
|
||||||
piece.shape = new_piece.shape
|
end
|
||||||
elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then
|
end
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
|
||||||
piece.shape = new_piece.shape
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Trans
|
return Trans
|
Loading…
Reference in New Issue