mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 02:19:02 -06:00
Merge pull request #62 from Tetro48/replay-qol
New replay file naming and fast replay saving.
This commit is contained in:
commit
5d2da1b4fb
@ -144,21 +144,18 @@ function GameMode:saveReplay()
|
|||||||
if love.filesystem.getInfo("replays") == nil then
|
if love.filesystem.getInfo("replays") == nil then
|
||||||
love.filesystem.createDirectory("replays")
|
love.filesystem.createDirectory("replays")
|
||||||
end
|
end
|
||||||
local replay_files = love.filesystem.getDirectoryItems("replays")
|
local init_name = string.format("replays/%s.crp", os.date("%Y-%m-%d_%H-%M-%S"))
|
||||||
-- Select replay filename that doesn't collide with an existing one
|
local replay_name = init_name
|
||||||
local replay_number = 0
|
local replay_number = 0
|
||||||
local collision = true
|
while true do
|
||||||
while collision do
|
if love.filesystem.getInfo(replay_name, "file") then
|
||||||
collision = false
|
|
||||||
replay_number = replay_number + 1
|
replay_number = replay_number + 1
|
||||||
for key, file in pairs(replay_files) do
|
replay_name = string.format("%s (%d)", init_name, replay_number)
|
||||||
if file == replay_number..".crp" then
|
else
|
||||||
collision = true
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
love.filesystem.write(replay_name, binser.serialize(replay))
|
||||||
love.filesystem.write("replays/"..replay_number..".crp", binser.serialize(replay))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:addReplayInput(inputs)
|
function GameMode:addReplayInput(inputs)
|
||||||
|
Loading…
Reference in New Issue
Block a user