my code looks alike from what you have given me
local function loadStatus(filename) local path = system.pathForFile( filename, system.DocumentsDirectory) local contents = "" local myTable = {} local file = io.open( path, "r" ) if file then -- read all contents of file into a string local contents = file:read( "\*a" ) myTable = json.decode(contents); io.close( file ) return myTable end return nil end M.loadStatus=loadStatus local function saveStatus(filename, save) local path = system.pathForFile( filename, system.DocumentsDirectory) local file = io.open(path, "w") if file then local contents = json.encode(save) file:write( contents ) io.close( file ) return true else return false end end M.saveStatus=saveStatus
what driving me nuts is that I can’t event know if it is actually saving, as i can’t open the file in the temp section
of the project sandbox. at the few first on simulator it will work, but a few mins later it will not recognize the filename,
and when i print, it throw me the filename instead of a table reference
//main.lua \_played = lib.loadStatus('level\_status.json') print(\_played, 'played') //this one will print table reference number, //but later will just print level\_status.json if \_played == nil then print('check') \_played = {} for i = 1, 5 do \_played[i] = {} for j = 1, 21 do if j == 21 then \_played[i][j] = 0 end \_played[i][j] = 1 print('enter') end end lib.saveStatus('level\_status.json', \_played) end