Well, you already got nice links.
I'll add a pinch of salt though, about the saving system.
First, do use
love.filesystem.setidentity to set the save folder path (the inside Appdata/love user directory)
Then you can proceed as said before, packing your variables into a regular Lua table.
Code: Select all
function love.load()
love.filesystem.setIdentity('MyGame')
data = {}
data.page = 1
data.next_text = 10
data.upper_limit = 20
data.lower_limit = 0
end
Now, you can use a basic snippet to turn your table into a string:
Code: Select all
function _tostring(data)
local buf = 'return {'
for i,v in pairs(data) do
buf = buf .. i ..' = '..v..','
end
buf = buf .. '}'
return buf
end
Assuming that, saving and loading data is now fairly simple:
Code: Select all
function save(data)
love.filesystem.write('sav',_tostring(data))
end
function load(file)
return loadfile(love.filesystem.getSaveDirectory()..'/'..file)()
end
Loadfile is legible here just because data were previously written in a way it can be parsed by Lua.
See
loadfile,
Lua tables for more details.
That's a very simple example. According o your needs you may want something more improved, or not.