Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------
- --READ AND WRITE TO FILE [cred to Bogdan Vladu and LevelHelper]
- -- THIS ONE HANDLES THE VARIABLE currentLevel
- ----------------------
- function saveProgress( currentLevel )
- local path = system.pathForFile( "myTextfile.txt", system.DocumentsDirectory )
- local file = io.open( path, "w+b" )
- file:write(currentLevel)
- io.close( file )
- end
- function loadProgress()
- local currentLevel = 1
- local path = system.pathForFile( "myTextfile.txt", system.DocumentsDirectory )
- local file = io.open( path, "r" )
- if file then
- local contents = file:read( "*a" )
- currentLevel = tonumber(contents)
- io.close( file )
- end
- return currentLevel
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement