In Corona, it is possible to save scores to an external text file. This can be accomplished using the following lines of code :
|
1 2 3 4 |
local filePath = system.pathForFile( "score.txt", system.DocumentsDirectory ) // Here we are giving the path of the file to be opened and used as score.txt in the documents directory of the application. local myfile = io.open( filePath, "w" ) // We are opening the score.txt in write(w) mode so that we can write to it. File handling is done by the io class. So we are using the open method of io to open the external file. myfile:write(scoreStr) // We are writing the scoreStr, which is the string which contains the score value to the opened file using the write method. io.close(myfile) // After our use for the opened file, we have to close the file using the close method of io. |
This code snippet will save the score value in the scoreStr variable to the the file score.txt.



