Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- savefile = maps[toload].. ".txt"
- print (savefile) -- prints fooWorld.txt
- _disk.saveTable( map2process, savefile, system.ResourceDirectory )
- ---- here is the loadsave mod
- local this = {}
- --local json = require("json")
- local json = require "json"
- local DefaultLocation = system.DocumentsDirectory
- local RealDefaultLocation = DefaultLocation
- local ValidLocations = {
- [system.DocumentsDirectory] = true,
- [system.ResourceDirectory] = true,
- [system.CachesDirectory] = true,
- [system.TemporaryDirectory] = true
- }
- function this.saveTable(t, filename, location)
- print (" STUFF 'SAVED' to DISK ")
- if location and (not ValidLocations[location]) then
- error("Attempted to save a table to an invalid location", 2)
- elseif not location then
- location = DefaultLocation
- end
- local path = system.pathForFile( filename, location)
- local file = io.open(path, "w")
- if file then
- local contents = json.encode(t)
- file:write( contents )
- io.close( file )
- return true
- else
- print ("cant find:" .. t,filename,location)
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement