Check out this bit of code from Rob Miracle:
http://developer.coronalabs.com/code/super-simple-lua-table-save-and-load-file-functions
Store this in a local table (I call mine dataAccess).Then, in main, setup something that tests if the json file exists and creates a new one if it isn’t. This new file will persist between launches.
[lua] local dataAccess = require(“loadsave”)
local gameData = dataAccess.loadTable( “gameData.json” )
local setupGameData = function()
gameData.isFirstLaunch = true
gameData.numLaunches = 1
end
if not gameData then
gameData = {}
setupGameData()
dataAccess.saveTable( gameData, “gameData.json” )
end[/lua]
Every time you need to check the number of launches, load up the table and see. Just be sure to use the saveTable function after you change it.
-Treb
[import]uid: 181948 topic_id: 33980 reply_id: 135085[/import]