- Most of the code you see in this function is the genius work of bartbes, from one of his responses to the SELOVE cracking challenge.
- I need this for a reusable level editor I'm about to make, which obviously needs to load and save files from various places.
Code: Select all
function setIdentity(to)
love.filesystem.setIdentity('tmp')
local new = ""
local path = love.filesystem.getSaveDirectory()
path = path:match("/(.+)") or path:match("%s:/(.+)")
for s in path:gmatch("/") do new = new .. "../" end
love.filesystem.setIdentity(new .. (to and to:gsub('^/', '') or ""))
end
Code: Select all
setIdentity("/Users/username/games/foo/blah") -- or (the first slash is irrelevant)
setIdentity("Users/username/games/foo/blah")
And no, the "tmp" save directory never gets created, so you won't have to worry about that.