Skip to content

Commit

Permalink
科研-极简模式优化
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Oct 10, 2023
1 parent 6ccebcf commit 769125a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
32 changes: 19 additions & 13 deletions parts/eventsets/tech_finesse_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ local function lockMovement(P)
lockKey(P,{1,2})
end
local function lockRotation(P)
lockKey(P,{3,4,5})
lockKey(P,{3,4})
end
local function lockRotation180(P)
lockKey(P,{5})
end
local function unlock(P)
if P.cur and P.cur.name==6 and not P.gameEnv.skipOCheck then -- don't unlock rotation if O piece & no O-spin
Expand All @@ -40,26 +43,27 @@ local function onMove(P)
P.holdTime=0
lockKey(P,{8})

-- return if overhang
if P:_roofCheck() then return end

P.modeData.moveCount=P.modeData.moveCount+1
if P.modeData.moveCount>=2 then lockMovement(P) end
if not P:_roofCheck() then
P.modeData.moveCount=P.modeData.moveCount+1
if P.modeData.moveCount>=2 then lockMovement(P) end
end
end
local function onAutoMove(P)
if P:_roofCheck() then unlock(P) end
end
local function onRotate(P)
local function onRotate(P,dir)
if not P.cur then return end

P.holdTime=0
lockKey(P,{8})

-- return if overhang
if P:_roofCheck() then return end

P.modeData.rotations=P.modeData.rotations+1
if P.modeData.rotations>=2 then lockRotation(P) end
if not P:_roofCheck() then
P.modeData.rotations=P.modeData.rotations+(dir==2 and 2 or 1)
lockRotation180(P)
if P.modeData.rotations>=2 then
lockRotation(P)
end
end
end

return {
Expand Down Expand Up @@ -91,6 +95,7 @@ return {
if P.gameEnv.skipOCheck then return end
if P.cur.name==6 then
lockRotation(P)
lockRotation180(P)
else
resetLock(P)
end
Expand All @@ -99,11 +104,12 @@ return {
if P.gameEnv.skipOCheck then return end
if P.cur.name==6 then
lockRotation(P)
lockRotation180(P)
else
resetLock(P)
end
end,
hook_left_manual=onMove, hook_right_manual=onMove,
hook_left_auto=onAutoMove, hook_right_auto=onAutoMove,
hook_rotLeft=onRotate, hook_rotRight=onRotate, hook_rot180=onRotate,
hook_rotate=onRotate
}
34 changes: 20 additions & 14 deletions parts/eventsets/tech_finesse_lock_f.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ local function lockMovement(P)
lockKey(P,{1,2})
end
local function lockRotation(P)
lockKey(P,{3,4,5})
lockKey(P,{3,4})
end
local function lockRotation180(P)
lockKey(P,{5})
end
local function unlock(P)
if P.cur and P.cur.name==6 and not P.gameEnv.skipOCheck then -- don't unlock rotation if O piece & no O-spin
Expand All @@ -39,26 +42,27 @@ local function onMove(P)
P.holdTime=0
lockKey(P,{8})

-- return if overhang
if P:_roofCheck() then return end

P.modeData.moveCount=P.modeData.moveCount+1
if P.modeData.moveCount>=2 then lockMovement(P) end
if not P:_roofCheck() then
P.modeData.moveCount=P.modeData.moveCount+1
if P.modeData.moveCount>=2 then lockMovement(P) end
end
end
local function onAutoMove(P)
if P:_roofCheck() then unlock(P) end
end
local function onRotate(P)
local function onRotate(P,dir)
if not P.cur then return end

P.holdTime=0
lockKey(P,{8})

-- return if overhang
if P:_roofCheck() then return end

P.modeData.rotations=P.modeData.rotations+1
if P.modeData.rotations>=2 then lockRotation(P) end
if not P:_roofCheck() then
P.modeData.rotations=P.modeData.rotations+(dir==2 and 2 or 1)
lockRotation180(P)
if P.modeData.rotations>=2 then
lockRotation(P)
end
end
end

return {
Expand Down Expand Up @@ -98,6 +102,7 @@ return {
if P.gameEnv.skipOCheck then return end
if P.cur.name==6 then
lockRotation(P)
lockRotation180(P)
else
resetLock(P)
end
Expand All @@ -106,11 +111,12 @@ return {
if P.gameEnv.skipOCheck then return end
if P.cur.name==6 then
lockRotation(P)
lockRotation180(P)
else
resetLock(P)
end
end,
hook_left_manual=onMove, hook_right_manual=onMove,
hook_left_auto=onAutoMove, hook_right_auto=onAutoMove,
hook_rotLeft=onRotate, hook_rotRight=onRotate, hook_rot180=onRotate
}
hook_rotate=onRotate,
}
4 changes: 1 addition & 3 deletions parts/player/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ local hooks = {
'hook_right',
'hook_right_manual',
'hook_right_auto',
'hook_rotLeft',
'hook_rotRight',
'hook_rot180',
'hook_rotate',
'hook_drop',
'hook_spawn',
'hook_hold',
Expand Down
6 changes: 3 additions & 3 deletions parts/player/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function Player:act_rotRight()
if self.cur then
self.ctrlCount=self.ctrlCount+1
self:spin(1)
self:_triggerEvent('hook_rotRight')
self:_triggerEvent('hook_rotate',1)
self.keyPressing[3]=false
end
end
Expand All @@ -280,7 +280,7 @@ function Player:act_rotLeft()
if self.cur then
self.ctrlCount=self.ctrlCount+1
self:spin(3)
self:_triggerEvent('hook_rotLeft')
self:_triggerEvent('hook_rotate',3)
self.keyPressing[4]=false
end
end
Expand All @@ -289,7 +289,7 @@ function Player:act_rot180()
if self.cur then
self.ctrlCount=self.ctrlCount+2
self:spin(2)
self:_triggerEvent('hook_rot180')
self:_triggerEvent('hook_rotate',2)
self.keyPressing[5]=false
end
end
Expand Down

0 comments on commit 769125a

Please sign in to comment.