Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local path = system.pathForFile( "Version.txt", system.DocumentsDirectory )
- -- io.open opens a file at path. returns nil if no file found
- local file = io.open( path, "r" )
- if file then
- -- read all contents of file into a string
- local contents = file:read( "*a" )
- local decodeVersion = json.decode(contents)
- -- print( "Contents of " .. path .. "\n" .. contents )
- io.close( file )
- layout.elements.Text_VersionNumber.text = ( gameInstallation[1] )
- else
- -- create file b/c it doesn't exist yet <------ The game Version
- file = io.open( path, "w" )
- local gameInstallation = {Version = .07, SaveDisk = 0 }
- local encodedVersion = json.encode (gameInstallation)
- file:write( gameInstallation )
- for _,v in ipairs( gameInstallation ) do file:write( v, " " ) end
- file:write( "\nNo more data\n" )
- io.close( file )
- -- layout.elements.Text_VersionNumber.text = ( ) )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement