Shorten code, remove `unranked`

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-01-04 10:19:38 +07:00
parent 8252f85720
commit e6f416eee3
4 changed files with 43 additions and 58 deletions

View File

@@ -506,10 +506,8 @@ function mergeStat(stat,delta)-- Merge delta stat. to global stat.
end
end
function scoreValid()-- Check if any unranked mods are activated
for number,sel in next,GAME.mod do
if sel>0 and MODOPT[number].unranked then
return false
end
for _,sel in next,GAME.mod do
if sel>0 then return false end
end
if GAME.playing and GAME.tasUsed then
return false

View File

@@ -354,59 +354,51 @@ do-- Mod data
local function _disableKey(P,key)
table.insert(P.gameEnv.keyCancel,key)
end
MODOPT={-- Mod options
MODOPT={-- Mod options | P for Player, O for Option, F for Force/Mod patch
{no=0,id="NX",name="next",
key="q",x=80,y=230,color='lO',
list={0,1,2,3,4,5,6},
func=function(P,O) P.gameEnv.nextCount=O end,
unranked=true,
},
{no=1,id="HL",name="hold",
key="w",x=200,y=230,color='lO',
list={0,1,2,3,4,5,6},
func=function(P,O,F)
if P.gameEnv.holdCount==O then return end
if F then P:setHold(O) else P.gameEnv.holdCount=O end end,
unranked=true,
if F then P:setHold(O) else P.gameEnv.holdCount=O end
end,
},
{no=2,id="FL",name="hideNext",
key="e",x=320,y=230,color='lA',
list={1,2,3,4,5},
func=function(P,O) P.gameEnv.nextStartPos=O+1 end,
unranked=true,
},
{no=3,id="IH",name="infHold",
key="r",x=440,y=230,color='lA',
func=function(P) P.gameEnv.infHold=true end,
unranked=true,
},
{no=4,id="HB",name="hideBlock",
key="y",x=680,y=230,color='lV',
func=function(P) P.gameEnv.block=false end,
unranked=true,
},
{no=5,id="HG",name="hideGhost",
key="u",x=800,y=230,color='lV',
func=function(P) P.gameEnv.ghost=false end,
unranked=true,
},
{no=6,id="HD",name="hidden",
key="i",x=920,y=230,color='lP',
list={'easy','slow','medium','fast','none'},
func=function(P,O) P.gameEnv.visible=O end,
unranked=true,
},
{no=7,id="HB",name="hideBoard",
key="o",x=1040,y=230,color='lP',
list={'down','up','all'},
func=function(P,O) P.gameEnv.hideBoard=O end,
unranked=true,
},
{no=8,id="FB",name="flipBoard",
key="p",x=1160,y=230,color='lJ',
list={'U-D','L-R','180'},
func=function(P,O) P.gameEnv.flipBoard=O end,
unranked=true,
},
{no=9,id="DT",name="dropDelay",
@@ -417,41 +409,34 @@ do-- Mod data
P.gameEnv.drop=O
if F then P:set20G(O==0) end
end,
unranked=true,
},
{no=10,id="LT",name="lockDelay",
key="s",x=260,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,25,30,40,60,180,1e99},
func=function(P,O) P.gameEnv.lock=O end,
unranked=true,
},
{no=11,id="ST",name="waitDelay",
key="d",x=380,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,10,15,20,30,60},
func=function(P,O) P.gameEnv.wait=O end,
unranked=true,
},
{no=12,id="CT",name="fallDelay",
key="f",x=500,y=350,color='lR',
list={0,1,2,3,4,5,6,7,8,10,15,20,30,60},
func=function(P,O) P.gameEnv.fall=O end,
unranked=true,
},
{no=13,id="LF",name="life",
key="j",x=860,y=350,color='lY',
list={0,1,2,3,5,10,15,26,42,87,500},
func=function(P,O) P.gameEnv.life=O end,
unranked=true,
},
{no=14,id="FB",name="forceB2B",
key="k",x=980,y=350,color='lY',
func=function(P) P.gameEnv.b2bKill=true end,
unranked=true,
},
{no=15,id="PF",name="forceFinesse",
key="l",x=1100,y=350,color='lY',
func=function(P) P.gameEnv.fineKill=true end,
unranked=true,
},
{no=16,id="TL",name="tele",
@@ -460,7 +445,6 @@ do-- Mod data
P.gameEnv.das,P.gameEnv.arr=0,0
P.gameEnv.sddas,P.gameEnv.sdarr=0,0
end,
unranked=true,
},
{no=17,id="FX",name="noRotation",
key="x",x=320,y=470,color='lH',
@@ -469,7 +453,6 @@ do-- Mod data
_disableKey(P,4)
_disableKey(P,5)
end,
unranked=true,
},
{no=18,id="GL",name="noMove",
key="c",x=440,y=470,color='lH',
@@ -479,25 +462,34 @@ do-- Mod data
_disableKey(P,17)_disableKey(P,18)
_disableKey(P,19)_disableKey(P,20)
end,
unranked=true,
},
{no=19,id="CS",name="customSeq",
key="b",x=680,y=470,color='lB',
list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
func=function(P,O) P.gameEnv.sequence=O end,
unranked=true,
func=function(P,O)
if P.gameEnv.sequence==O then return end
P.gameEnv.sequence=O
if F then P:resetNext() end
end,
executeOnce=false,
},
{no=20,id="PS",name="pushSpeed",
key="n",x=800,y=470,color='lB',
list={.5,1,2,3,5,15,1e99},
func=function(P,O) P.gameEnv.pushSpeed=O end,
unranked=true,
},
{no=21,id="BN",name="boneBlock",
key="m",x=920,y=470,color='lB',
list={'on','off'},
func=function(P,O) P.gameEnv.bone=O=='on' end,
unranked=true,
func=function(P,O,F)
if P.gameEnv.bone==O then return end
P.gameEnv.bone=O
if F and O=='on' then
for _,bk in pairs(P.nextQueue) do
bk.color=17 --Bone block
end
end
end,
},
}
for i=1,#MODOPT do

View File

@@ -203,13 +203,6 @@ local function _loadGameEnv(P)-- Load gameEnv
if GAME.modPatch then
if not GAME.modCodeList then GAME.modCodeList={} end
if not GAME.modCodeList[P.id] then GAME.modCodeList[P.id]={} end
for i=1,#GAME.mod do
if GAME.mod[i]>0 then
local M=MODOPT[i]
table.insert(GAME.modCodeList[P.id], function() M.func(P,M.list and M.list[GAME.mod[i]],true) end)
end
end
if not GAME.ApplyModsTask then
GAME.ApplyModsTask=function()
while GAME.playing do
@@ -226,12 +219,15 @@ local function _loadGameEnv(P)-- Load gameEnv
end
TASK.new(GAME.ApplyModsTask)
end
else
for i=1,#GAME.mod do
if GAME.mod[i]>0 then
local M=MODOPT[i]
M.func(P,M.list and M.list[GAME.mod[i]],false)
end
for i=1,#GAME.mod do
if GAME.mod[i]>0 then
local M=MODOPT[i]
if not GAME.modPatch or M.executeOnce then
M.func(P,M.list and M.listpGAME.mod[i],false)
else
table.insert(GAME.modCodeList[P.id], function() M.func(P,M.list and M.list[GAME.mod[i]],true) end)
end
end
end
@@ -400,9 +396,14 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
P:newNext()
end
end
for _=1,ENV.trueNextCount do
P:newNext()
function P:resetNext()
seqGen=coroutine.create(getSeqGen(ENV.sequence))
seqCalled=false
initSZOcount=0
bagLineCounter=0
for _=1,ENV.trueNextCount do self:newNext() end
end
P:resetNext()
if P.miniMode then
ENV.lockFX=false

View File

@@ -14,13 +14,12 @@ local function _toggleMod(M,back)
else
GAME.mod[number]=1-GAME.mod[number]
end
if M.unranked then
SFX.play('touch',.6)
SFX.play('lock')
else
SFX.play('touch')
SFX.play('lock',.6)
end
-- Unranked
SFX.play('touch',.6)
SFX.play('lock')
-- Still ranked
-- SFX.play('touch')
-- SFX.play('lock',.6)
scene.widgetList.unranked.hide=scoreValid()
end
@@ -104,12 +103,7 @@ function scene.draw()
local t=M.time*.01-- t range:0~0.1
GC.scale(1+3*t)
GC.rotate(t)
local rad,side
if M.unranked then
rad,side=45,5
else
rad=40
end
local rad,side=45,5 -- rad=40 --> circle (but that will be a story in the future)
local color=M.color
GC.setColor(color[1],color[2],color[3],5*t)
GC.circle('fill',0,0,rad,side)