From 1c31015fa81eecbae2830ea6686ad5643ee5b72d Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 19 Nov 2020 20:39:15 +0800 Subject: [PATCH] =?UTF-8?q?default=5Fdata=E6=96=87=E4=BB=B6=E6=94=B9?= =?UTF-8?q?=E5=90=8DglobalTables=EF=BC=8Cmain=E4=B8=AD=E5=85=A8=E5=B1=80ta?= =?UTF-8?q?ble=E5=A3=B0=E6=98=8E=E7=BB=9F=E4=B8=80=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 83 +---------- parts/default_data.lua | 111 -------------- parts/gametoolfunc.lua | 12 +- parts/globalTables.lua | 310 ++++++++++++++++++++++++++++++++++++++++ parts/modOption.lua | 101 +++++++++++++ parts/player/draw.lua | 4 +- parts/player/init.lua | 6 +- parts/player/player.lua | 4 +- 8 files changed, 423 insertions(+), 208 deletions(-) delete mode 100644 parts/default_data.lua create mode 100644 parts/globalTables.lua create mode 100644 parts/modOption.lua diff --git a/main.lua b/main.lua index 364f2147..9ea6750a 100644 --- a/main.lua +++ b/main.lua @@ -29,92 +29,11 @@ love.keyboard.setKeyRepeat(true) love.keyboard.setTextInput(false) love.mouse.setVisible(false) -MODOPT={ - -- nextStartPos=2, - -- drop=0, - -- lock=0, -} -CUSTOMENV={ - --Basic - drop=60, - lock=60, - wait=0, - fall=0, - - nextCount=6, - nextStartPos=1, - holdCount=1, - infHold=false, - - --Visual - block=true, - ghost=.3, - center=1, - bagLine=false, - highCam=false, - nextPos=false, - bone=false, - - --Rule - mindas=0, - minarr=0, - minsdarr=0, - sequence="bag", - ospin=true, - RS="TRS", - - noTele=false, - fineKill=false, - missionKill=false, - easyFresh=true, - visible="show", - target=1e99, - freshLimit=1e99, - opponent=0, - life=0, - pushSpeed=3, - - --Else - bg="none", - bgm="race" -} -FIELD={}--Field(s) for custom game -BAG={}--Sequence for custom game -MISSION={}--Clearing mission for custom game - -GAME={ - frame=0, --Frame count - result=false, --Game result (string) - pauseTime=0, --Time paused - pauseCount=0, --Pausing count - garbageSpeed=1, --Garbage timing speed - warnLVL0=0, --Warning level - warnLVL=0, --Warning level (show) - recording=false, --If recording - replaying=false, --If replaying - seed=math.random(2e6),--Game seed - setting={}, --Game settings - rec={}, --Recording list, key,time,key,time... - rank=nil, --Rank reached - - prevBG=nil, --Previous background, for restore BG when quit setting page - - --Data for royale mode - stage=nil, --Game stage - mostBadge=nil, --Most badge owner - secBadge=nil, --Second badge owner - mostDangerous=nil, --Most dangerous player - secDangerous=nil, --Second dangerous player -}--Global game data -PLAYERS={alive={}}--Players data -CURMODE=nil--Current mode object -RANKS={sprint_10=0} - --Load modules require("Zframework") require("parts/list") -require("parts/default_data") +require("parts/globalTables") require("parts/gametoolfunc") SCR.setSize(1280,720)--Initialize Screen size diff --git a/parts/default_data.lua b/parts/default_data.lua deleted file mode 100644 index 7a6c409b..00000000 --- a/parts/default_data.lua +++ /dev/null @@ -1,111 +0,0 @@ -SETTING={ - --Game - das=10,arr=2, - sddas=0,sdarr=2, - ihs=true,irs=true,ims=true, - maxNext=6, - RS="TRS", - swap=true, - - --System - reTime=4, - autoPause=true, - fine=false, - appLock=false, - lang=1, - skinSet=1, - skin={1,7,11,3,14,4,9,1,7,1,7,11,3,14,4,9,14,9,11,3,11,3,1,7,4}, - face={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - - --Graphic - block=true,ghost=.3,center=1, - smooth=true,grid=false, - bagLine=false, - lockFX=2, - dropFX=2, - moveFX=2, - clearFX=2, - shakeFX=2, - atkFX=3, - frameMul=100, - - text=true, - score=true, - warn=true, - highCam=false, - nextPos=false, - fullscreen=false, - bg=true, - powerInfo=false, - - --Sound - sfx=1, - spawn=0, - bgm=.7, - stereo=.6, - vib=0, - voc=0, - cv="miya", - - --Virtualkey - VKSFX=.2,--SFX volume - VKVIB=0,--VIB - VKSwitch=false,--If disp - VKTrack=false,--If tracked - VKDodge=false,--If dodge - VKTchW=3,--Touch-Pos Weight - VKCurW=4,--Cur-Pos Weight - VKIcon=true,--If disp icon - VKAlpha=.3, -} - -STAT={ - version=VERSION, - run=0,game=0,time=0, - key=0,rotate=0,hold=0, - extraPiece=0,finesseRate=0, - piece=0,row=0,dig=0, - atk=0,digatk=0, - send=0,recv=0,pend=0,off=0, - clear={},spin={}, - pc=0,hpc=0,b2b=0,b3b=0,score=0, - lastPlay="sprint_10",--Last played mode ID -} -for i=1,25 do - STAT.clear[i]={0,0,0,0,0,0} - STAT.spin[i]={0,0,0,0,0,0,0} -end - -keyMap={ - {"left","right","x","z","c","up","down","space","tab","r"},{}, - --Keyboard - {"dpleft","dpright","a","b","y","dpup","dpdown","rightshoulder","x","leftshoulder"},{}, - --Joystick -} -for i=1,#keyMap do for j=1,20 do - if not keyMap[i][j]then keyMap[i][j]=""end -end end - -VK_org={--Original virtualkey set,for restore VKs' position before each game - {ava=true, x=80, y=720-200, r=80},--moveLeft - {ava=true, x=320, y=720-200, r=80},--moveRight - {ava=true, x=1280-80, y=720-200, r=80},--rotRight - {ava=true, x=1280-200, y=720-80, r=80},--rotLeft - {ava=true, x=1280-200, y=720-320, r=80},--rot180 - {ava=true, x=200, y=720-320, r=80},--hardDrop - {ava=true, x=200, y=720-80, r=80},--softDrop - {ava=true, x=1280-320, y=720-200, r=80},--hold - {ava=true, x=1280-80, y=280, r=80},--func - {ava=true, x=80, y=280, r=80},--restart - {ava=false, x=100, y=50, r=80},--insLeft - {ava=false, x=200, y=50, r=80},--insRight - {ava=false, x=300, y=50, r=80},--insDown - {ava=false, x=400, y=50, r=80},--down1 - {ava=false, x=500, y=50, r=80},--down4 - {ava=false, x=600, y=50, r=80},--down10 - {ava=false, x=700, y=50, r=80},--dropLeft - {ava=false, x=800, y=50, r=80},--dropRight - {ava=false, x=900, y=50, r=80},--addToLeft - {ava=false, x=1000, y=50, r=80},--addToRight -} -virtualkey={}for i=1,#VK_org do virtualkey[i]={}end \ No newline at end of file diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index f84f9ed8..94132f6f 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -387,7 +387,7 @@ function royaleLevelup() for i=1,#PLAYERS.alive do PLAYERS.alive[i].gameEnv.drop=spd end - if CURMODE.name:find("ultimate")then + if GAME.curMode.name:find("ultimate")then for i=1,#PLAYERS.alive do local P=PLAYERS.alive[i] P.gameEnv.drop=int(P.gameEnv.drop*.3) @@ -423,7 +423,7 @@ function resumeGame() end function loadGame(M,ifQuickPlay) STAT.lastPlay=M - CURMODE=MODES[M] + GAME.curMode=MODES[M] drawableText.modeName:set(text.modes[M][1]) drawableText.levelName:set(text.modes[M][2]) needResetGameData=true @@ -451,9 +451,9 @@ function resetGameData() GAME.seed=rnd(261046101471026) destroyPlayers() - MODEENV=CURMODE.env + MODEENV=GAME.curMode.env restoreVirtualKey() - CURMODE.load() + GAME.curMode.load() if MODEENV.task then for i=1,#PLAYERS do PLAYERS[i]:newTask(MODEENV.task) @@ -508,9 +508,9 @@ function resetPartGameData(replaying) end destroyPlayers() - MODEENV=CURMODE.env + MODEENV=GAME.curMode.env restoreVirtualKey() - CURMODE.load() + GAME.curMode.load() if MODEENV.task then for i=1,#PLAYERS do PLAYERS[i]:newTask(MODEENV.task) diff --git a/parts/globalTables.lua b/parts/globalTables.lua new file mode 100644 index 00000000..35f9be56 --- /dev/null +++ b/parts/globalTables.lua @@ -0,0 +1,310 @@ +MODOPT={--Mod options + { + name="noRotation", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="noMove", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="suddenMove", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + + { + name="noNext", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="noHold", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hideNext", + list={0,1,2,3,4,5,6}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hideBlock", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hideGhost", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + + { + name="mirror", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="flip", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hidden", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hideUp", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="hideDown", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + + { + name="_20G", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="suddenLock", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, + { + name="infLives", + list={false,true}, + sel=1, + code=function(P)end, + time=0, + }, +} + +CUSTOMENV={--gameEnv for cutsom game + --Basic + drop=60, + lock=60, + wait=0, + fall=0, + + nextCount=6, + nextStartPos=1, + holdCount=1, + infHold=false, + + --Visual + block=true, + ghost=.3, + center=1, + bagLine=false, + highCam=false, + nextPos=false, + bone=false, + + --Rule + mindas=0, + minarr=0, + minsdarr=0, + sequence="bag", + ospin=true, + RS="TRS", + + noTele=false, + fineKill=false, + missionKill=false, + easyFresh=true, + visible="show", + target=1e99, + freshLimit=1e99, + opponent=0, + life=0, + pushSpeed=3, + + --Else + bg="none", + bgm="race" +} + +FIELD={}--Field(s) for custom game + +BAG={}--Sequence for custom game + +MISSION={}--Clearing mission for custom game + +GAME={--Global game data + frame=0, --Frame count + result=false, --Game result (string) + pauseTime=0, --Time paused + pauseCount=0, --Pausing count + garbageSpeed=1, --Garbage timing speed + warnLVL0=0, --Warning level + warnLVL=0, --Warning level (show) + recording=false, --If recording + replaying=false, --If replaying + seed=math.random(2e6),--Game seed + curMode=nil, --Current gamemode object + setting={}, --Game settings + rec={}, --Recording list, key,time,key,time... + rank=nil, --Rank reached + + prevBG=nil, --Previous background, for restore BG when quit setting page + + --Data for royale mode + stage=nil, --Game stage + mostBadge=nil, --Most badge owner + secBadge=nil, --Second badge owner + mostDangerous=nil, --Most dangerous player + secDangerous=nil, --Second dangerous player +} + +PLAYERS={alive={}}--Players data + +RANKS={sprint_10=0} + +SETTING={ + --Game + das=10,arr=2, + sddas=0,sdarr=2, + ihs=true,irs=true,ims=true, + maxNext=6, + RS="TRS", + swap=true, + + --System + reTime=4, + autoPause=true, + fine=false, + appLock=false, + lang=1, + skinSet=1, + skin={1,7,11,3,14,4,9,1,7,1,7,11,3,14,4,9,14,9,11,3,11,3,1,7,4}, + face={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + + --Graphic + block=true,ghost=.3,center=1, + smooth=true,grid=false, + bagLine=false, + lockFX=2, + dropFX=2, + moveFX=2, + clearFX=2, + shakeFX=2, + atkFX=3, + frameMul=100, + + text=true, + score=true, + warn=true, + highCam=false, + nextPos=false, + fullscreen=false, + bg=true, + powerInfo=false, + + --Sound + sfx=1, + spawn=0, + bgm=.7, + stereo=.6, + vib=0, + voc=0, + cv="miya", + + --Virtualkey + VKSFX=.2,--SFX volume + VKVIB=0,--VIB + VKSwitch=false,--If disp + VKTrack=false,--If tracked + VKDodge=false,--If dodge + VKTchW=3,--Touch-Pos Weight + VKCurW=4,--Cur-Pos Weight + VKIcon=true,--If disp icon + VKAlpha=.3, +} + +STAT={ + version=VERSION, + run=0,game=0,time=0, + key=0,rotate=0,hold=0, + extraPiece=0,finesseRate=0, + piece=0,row=0,dig=0, + atk=0,digatk=0, + send=0,recv=0,pend=0,off=0, + clear={},spin={}, + pc=0,hpc=0,b2b=0,b3b=0,score=0, + lastPlay="sprint_10",--Last played mode ID +} +for i=1,25 do + STAT.clear[i]={0,0,0,0,0,0} + STAT.spin[i]={0,0,0,0,0,0,0} +end + +keyMap={ + {"left","right","x","z","c","up","down","space","tab","r"},{}, + --Keyboard + {"dpleft","dpright","a","b","y","dpup","dpdown","rightshoulder","x","leftshoulder"},{}, + --Joystick +} +for i=1,#keyMap do for j=1,20 do + if not keyMap[i][j]then keyMap[i][j]=""end +end end + +VK_org={--Original virtualkey set,for restore VKs' position before each game + {ava=true, x=80, y=720-200, r=80},--moveLeft + {ava=true, x=320, y=720-200, r=80},--moveRight + {ava=true, x=1280-80, y=720-200, r=80},--rotRight + {ava=true, x=1280-200, y=720-80, r=80},--rotLeft + {ava=true, x=1280-200, y=720-320, r=80},--rot180 + {ava=true, x=200, y=720-320, r=80},--hardDrop + {ava=true, x=200, y=720-80, r=80},--softDrop + {ava=true, x=1280-320, y=720-200, r=80},--hold + {ava=true, x=1280-80, y=280, r=80},--func + {ava=true, x=80, y=280, r=80},--restart + {ava=false, x=100, y=50, r=80},--insLeft + {ava=false, x=200, y=50, r=80},--insRight + {ava=false, x=300, y=50, r=80},--insDown + {ava=false, x=400, y=50, r=80},--down1 + {ava=false, x=500, y=50, r=80},--down4 + {ava=false, x=600, y=50, r=80},--down10 + {ava=false, x=700, y=50, r=80},--dropLeft + {ava=false, x=800, y=50, r=80},--dropRight + {ava=false, x=900, y=50, r=80},--addToLeft + {ava=false, x=1000, y=50, r=80},--addToRight +} +virtualkey={}for i=1,#VK_org do virtualkey[i]={}end \ No newline at end of file diff --git a/parts/modOption.lua b/parts/modOption.lua new file mode 100644 index 00000000..69c8bae2 --- /dev/null +++ b/parts/modOption.lua @@ -0,0 +1,101 @@ +return{ + { + name="noRotation", + list={false,true}, + sel=1, + time=0, + }, + { + name="noMove", + list={false,true}, + sel=1, + time=0, + }, + { + name="suddenMove", + list={false,true}, + sel=1, + time=0, + }, + + { + name="noNext", + list={false,true}, + sel=1, + time=0, + }, + { + name="noHold", + list={false,true}, + sel=1, + time=0, + }, + { + name="hideNext", + list={0,1,2,3,4,5,6}, + sel=1, + time=0, + }, + { + name="hideBlock", + list={false,true}, + sel=1, + time=0, + }, + { + name="hideGhost", + list={false,true}, + sel=1, + time=0, + }, + + { + name="mirror", + list={false,true}, + sel=1, + time=0, + }, + { + name="flip", + list={false,true}, + sel=1, + time=0, + }, + { + name="hidden", + list={false,true}, + sel=1, + time=0, + }, + { + name="hideUp", + list={false,true}, + sel=1, + time=0, + }, + { + name="hideDown", + list={false,true}, + sel=1, + time=0, + }, + + { + name="_20G", + list={false,true}, + sel=1, + time=0, + }, + { + name="suddenLock", + list={false,true}, + sel=1, + time=0, + }, + { + name="infLives", + list={false,true}, + sel=1, + time=0, + }, +} \ No newline at end of file diff --git a/parts/player/draw.lua b/parts/player/draw.lua index 27f9ec6f..4859c5d5 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -533,8 +533,8 @@ function draw.norm(P) --Other messages gc.setColor(1,1,1) - if CURMODE.mesDisp then - CURMODE.mesDisp(P) + if GAME.curMode.mesDisp then + GAME.curMode.mesDisp(P) end --Missions diff --git a/parts/player/init.lua b/parts/player/init.lua index 11c38f64..a5b83996 100644 --- a/parts/player/init.lua +++ b/parts/player/init.lua @@ -192,15 +192,11 @@ end local function loadGameEnv(P)--Load gameEnv P.gameEnv={}--Current game setting environment local ENV=P.gameEnv - local MODOPT=MODOPT local GAME=GAME local SETTING=SETTING --Load game settings for k,v in next,gameEnv0 do - if MODOPT[k]~=nil then - v=MODOPT[k] --Mod setting - -- DBP("mod-"..k..":"..tostring(v)) - elseif MODEENV[k]~=nil then + if MODEENV[k]~=nil then v=MODEENV[k] --Mode setting -- DBP("mode-"..k..":"..tostring(v)) elseif GAME.setting[k]~=nil then diff --git a/parts/player/player.lua b/parts/player/player.lua index e4db6785..f3e8377c 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -1327,7 +1327,7 @@ end local function gameOver()--Save record if GAME.replaying then return end FILE.saveData() - local M=CURMODE + local M=GAME.curMode local R=M.getRank if R then local P=PLAYERS[1] @@ -1411,7 +1411,7 @@ function Player.win(P,result) BGM.play("8-bit happiness") end end - if CURMODE.id=="custom_puzzle"then + if GAME.curMode.id=="custom_puzzle"then P:showTextF(text.win,0,0,90,"beat",.4) else P:showTextF(text.win,0,0,90,"beat",.5,.2)