There’s a popular term in business called “Eating your own dog food”. In other words, “use your own products”. I had that opportunity during my recent upgrade to Tappy Holidays. I wanted to add a persistent high score and a game counter for achievements, and what better way to do that than with GBC Data Cabinet.
GBC Data Cabinet is a Corona SDK library I wrote to manage temporary and persistent data within your application. It’s on Corona’s plug-in store, and it’s free! Let me know what you think.
The following is the code I used to check for an existing persistent cabinet file. If it does not exist, then create one, and get it ready for upcoming data during game play. If persistent data does exist, then read the values.
CabExist = GBCDataCab.load("playerdata") if CabExist == false then CabExist = GBCDataCab.createCabinet("playerdata") end if CabExist then highScore = GBCDataCab.get("playerdata", "highscore") if highScore == nil then highScore = 0 end intTotalGamesPlayed = GBCDataCab.get("playerdata", "gamesplayed") if intTotalGamesPlayed == nil then intTotalGamesPlayed = 0 end else highScore = 0 intTotalGamesPlayed = 0 end