resetGameData参数更高级

This commit is contained in:
MrZ626
2020-12-21 08:37:15 +08:00
parent a97fc8b53a
commit a38e1f201d
4 changed files with 10 additions and 9 deletions

View File

@@ -537,7 +537,8 @@ local function tick_showMods()
end end
end end
end end
function resetGameData(replaying,ifQuick) function resetGameData(args)
if not args then args=""end
if PLAYERS[1]and not GAME.replaying and(GAME.frame>400 or GAME.result)then if PLAYERS[1]and not GAME.replaying and(GAME.frame>400 or GAME.result)then
mergeStat(STAT,PLAYERS[1].stat) mergeStat(STAT,PLAYERS[1].stat)
STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time
@@ -546,7 +547,7 @@ function resetGameData(replaying,ifQuick)
GAME.result=false GAME.result=false
GAME.warnLVL0=0 GAME.warnLVL0=0
GAME.warnLVL=0 GAME.warnLVL=0
if replaying then if args:find("r")then
GAME.frame=0 GAME.frame=0
GAME.recording=false GAME.recording=false
GAME.replaying=1 GAME.replaying=1
@@ -566,7 +567,7 @@ function resetGameData(replaying,ifQuick)
destroyPlayers() destroyPlayers()
GAME.curMode.load() GAME.curMode.load()
initPlayerPosition(ifQuick) initPlayerPosition(args:find("q"))
restoreVirtualKey() restoreVirtualKey()
if GAME.modeEnv.task then if GAME.modeEnv.task then
for i=1,#PLAYERS do for i=1,#PLAYERS do

View File

@@ -1839,9 +1839,9 @@ function Player.act_func(P)
end end
function Player.act_restart() function Player.act_restart()
if GAME.frame<240 then if GAME.frame<240 then
resetGameData(false,true) resetGameData("q")
elseif GAME.result then elseif GAME.result then
resetGameData(false,false) resetGameData()
else else
LOG.print(text.holdR,20,COLOR.orange) LOG.print(text.holdR,20,COLOR.orange)
end end

View File

@@ -137,11 +137,11 @@ function scene.keyDown(key)
GAME.prevBG=BG.cur GAME.prevBG=BG.cur
SCN.go("setting_sound") SCN.go("setting_sound")
elseif key=="r"then elseif key=="r"then
resetGameData(false,false) resetGameData()
SCN.swapTo("play","none") SCN.swapTo("play","none")
elseif key=="p"then elseif key=="p"then
if(GAME.result or GAME.replaying)and #PLAYERS==1 then if(GAME.result or GAME.replaying)and #PLAYERS==1 then
resetGameData(true,false) resetGameData("r")
SCN.swapTo("play","none") SCN.swapTo("play","none")
end end
elseif key=="o"then elseif key=="o"then

View File

@@ -30,7 +30,7 @@ function scene.sceneInit()
love.keyboard.setKeyRepeat(false) love.keyboard.setKeyRepeat(false)
GAME.restartCount=0 GAME.restartCount=0
if GAME.init then if GAME.init then
resetGameData(false,false) resetGameData()
GAME.init=nil GAME.init=nil
end end
noKey=GAME.replaying noKey=GAME.replaying
@@ -204,7 +204,7 @@ function scene.update(dt)
elseif P1.keyPressing[10]then elseif P1.keyPressing[10]then
GAME.restartCount=GAME.restartCount+1 GAME.restartCount=GAME.restartCount+1
if GAME.restartCount>20 then if GAME.restartCount>20 then
resetGameData(false,false) resetGameData()
return return
end end
elseif GAME.restartCount>0 then elseif GAME.restartCount>0 then