The folders could perhaps be:
Windows: C:\Documents and Settings\<user>\Application Data\love\<game>\save.lua
Linux: /home/<user>/.love/<game>/save.lua
Mac (if ever): /Users/<username>/love/<game>/save.lua
I first suggested that <game> could be the name of the file being run. Mike suggested that it could be the name of the file being run if there was no id attribute in the config file, in which case that would be used instead.
Code: Select all
# Config file
author = "Bob"
title = "Awesome game II"
id = "awesome-3e76e8d"
Ok, on to the interface:
Code: Select all
love.objects:newFile( file )
love.filesystem:open( file )
love.filesystem:close( file )
love.filesystem:write( file, string )
love.filesystem:read( file )
love.filesystem:append( file, string )
love.fileystem:include( file )
love.filesystem:enumerate( directory )
file:getSize()
Example use, saving the highscore as a string, but loading it as a Lua table.
Code: Select all
-- When saving the highscore:
file = love.objects:newFile( "highscore.lua" )
love.filesystem:open(file)
love.filesystem:write(file, "highscore = { bob = 2000, jane = 1000, harry = 500 }")
love.filesystem:close(file)
-- Loading later:
file = love.objects:newFile( "highscore.lua" )
love.filesystem:include(file) -- Parsed as Lua source.
-- highscore can be accessed:
local bobscore = highscore.bob -- 2000
Code: Select all
str = love.filesystem:read(file)
I haven't thought of everything, so please speak up if you see something you don't like. (Or if there's something you would like to see).