fix: replace deprecated function

This commit is contained in:
Kazhnuz 2021-04-05 12:07:21 +02:00
parent 207d37eddc
commit 1b0091937f

View file

@ -94,7 +94,7 @@ function Game:getMetadataFile(absolute)
local dir = "" local dir = ""
if absolute then if absolute then
dir = love.filesystem.getSaveDirectory() .. "/" dir = love.filesystem.getSaveDirectory() .. "/"
if not love.filesystem.exists(dir) then if not utils.filesystem.exists(dir) then
love.filesystem.createDirectory( "" ) love.filesystem.createDirectory( "" )
end end
end end
@ -104,11 +104,10 @@ function Game:getMetadataFile(absolute)
return filepath return filepath
end end
function Game:getMetadata() function Game:getMetadata()
local metadata = {} local metadata = {}
local filepath = self:getMetadataFile(true) local filepath = self:getMetadataFile(true)
if love.filesystem.exists("metadata.save") then if utils.filesystem.exists("metadata.save") then
metadata = binser.readFile(filepath)[1] metadata = binser.readFile(filepath)[1]
else else
metadata = self:newMetadata() metadata = self:newMetadata()
@ -153,7 +152,7 @@ function Game:read(save_id)
self.slot = save_id self.slot = save_id
if (self.slot > 0) then if (self.slot > 0) then
local filepath = self:getSaveFile(self.slot, true) local filepath = self:getSaveFile(self.slot, true)
if love.filesystem.exists("save" .. self.slot .. ".save") then if utils.filesystem.exists("save" .. self.slot .. ".save") then
local loadedDatas = binser.readFile(filepath) local loadedDatas = binser.readFile(filepath)
self:setData(loadedDatas[1]) self:setData(loadedDatas[1])
@ -175,7 +174,7 @@ function Game:getSaveFile(saveslot, absolute)
local dir = "" local dir = ""
if absolute then if absolute then
dir = love.filesystem.getSaveDirectory() .. "/" dir = love.filesystem.getSaveDirectory() .. "/"
if not love.filesystem.exists(dir) then if not utils.filesystem.exists(dir) then
love.filesystem.createDirectory( "" ) love.filesystem.createDirectory( "" )
end end
end end
@ -188,7 +187,7 @@ end
function Game:resetSaves() function Game:resetSaves()
for i=1, self.slotNumber do for i=1, self.slotNumber do
local filepath = self:getSaveFile(i, true) local filepath = self:getSaveFile(i, true)
if love.filesystem.exists("save" .. i .. ".save") then if utils.filesystem.exists("save" .. i .. ".save") then
love.filesystem.remove( "save" .. i .. ".save" ) love.filesystem.remove( "save" .. i .. ".save" )
end end
end end