How to create a save function in love2d?
1 answer
Sure. You can use various libraries. My current recommendation is Ser Binser (Ser is deprecated). This process is called "table serialization". Then you can do something like this to effectively create a "save".
local ser = require 'Path.to.ser'
local save
function love.load()
if love.filesystem.exists( 'Save.lua' ) then
save = love.filesystem.load( 'Save.lua' )
else
save = {} -- Put settings in here.
end
end
-- etc. etc.
function love.quit()
love.filesystem.write( 'Save.lua', save )
end
+3
source to share