Make a new FILE API and add a simple error screen in case most thing went down

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-26 16:39:08 +07:00
parent c45104ce88
commit 4b001cdf57
6 changed files with 117 additions and 49 deletions

View File

@@ -140,7 +140,7 @@ end
function GameMode:readGradeHistory()
if love.filesystem.getInfo(SAVE_DIR..self.player_name.."_grade_history.sav") then
self.grade_history = bitser.loadLoveFile(SAVE_DIR..self.player_name.."_grade_history.sav")
self.grade_history = FILE.read(SAVE_DIR..self.player_name.."_grade_history.sav")
else
self.grade_history = {1,2,0,0}
end
@@ -148,13 +148,13 @@ function GameMode:readGradeHistory()
self.starting_grade = self.grade
if self.grade > 1 then
local temp_grade = copy(self.grade_history); temp_grade[2] = 0
bitser.dumpLoveFile(SAVE_DIR..self.player_name.."_grade_history.sav", temp_grade)
FILE.write(SAVE_DIR..self.player_name.."_grade_history.sav", temp_grade)
end
end
function GameMode:readHiScores()
if love.filesystem.getInfo(HIscoreFILE) then
self.hi_scores = bitser.loadLoveFile(HIscoreFILE)
self.hi_scores = FILE.read(HIscoreFILE)
else
self.hi_scores = {"TRO",0,"MIT",0,"ROM",0,"ITR",0,"OMI",0}
end
@@ -220,7 +220,7 @@ function GameMode:updateHiScores()
self.hi_scores[score_position] = self.grade_score
hiscore_pos = {score_position-1, score_position}
end
bitser.dumpLoveFile(HIscoreFILE, self.hi_scores)
FILE.write(HIscoreFILE, self.hi_scores)
return hiscore_pos
end
@@ -684,7 +684,7 @@ function GameMode:onGameOver()
self:updateGradeHistory()
end
hiscore_pos = self:updateHiScores()
bitser.dumpLoveFile(SAVE_DIR..self.player_name.."_grade_history.sav", self.grade_history)
FILE.write(SAVE_DIR..self.player_name.."_grade_history.sav", self.grade_history)
self.did_grades = true
end
self:drawEndScoringInfo()