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
end end
function scoreValid()-- Check if any unranked mods are activated function scoreValid()-- Check if any unranked mods are activated
for number,sel in next,GAME.mod do for _,sel in next,GAME.mod do
if sel>0 and MODOPT[number].unranked then if sel>0 then return false end
return false
end
end end
if GAME.playing and GAME.tasUsed then if GAME.playing and GAME.tasUsed then
return false return false

View File

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

View File

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

View File

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