How to future-proof game data saving with GGData library? (or other librairies)

Hi guys,

I currently ICE but will switch to GGData on my next app. One thing that I found out is I cannot really change the setting of my ICE boxes at will. Of course because I need to keep the box organisation the same to stay compatible with previous versions of the app. So far that I did (not change the boxes) but I really would to be able to add new features to the app and be able to save the new items.

One way I guess will be to simply add new boxes to the update version but I was wondering if there is a way to simply modify past boxes to accomodate the new items to be saved. Those items could  numbers, strings or Boolean or even tables of other things.

I am very curious how people future-proof their data saving files. Be using ICE, GGData or other ways.

Thanks a lot!

Mo 

Any ideas? Anybody? I really want to start right and I am trying to avoid issues with updates when I need to add more variables for new features.

Thanks again.

Mo

Hey Mo, I’m not sure what exactly you mean by future proof? I’m using ggdata and I find it relatively easy to easy since you can throw lua tables at it. 

Thanks for getting back to me. Ok, let say I have a box with some variables that save some game data like score and highscore. Then later (a game update) I want to add some new features. Let say those features deals with powerups. So I need to add more variables to the box like powerup1 and powerup2 (Boolean) – Version 1.0 Box.score = 0 Box.hiscore = 0 – version 1.1 (update) Box:set(powerup1,true) Box:set(powerup2,false) Box:set(test,{“one”,“two”}) The question is what happen to people who upgrade to version version 1.1? Is GGData smart enough to read the previous version save data (1.0)? Please note that I did not yet used GGData. I am using ICE at this time so my question above maybe more related to the fact that I do not know how to add variables to ICE boxes without having reading issues on older app version (ie: using boxes with less variables…like above with GGData example) Not really sure I make any sense so please ask away if you need to:) THANKS again! Mo

I use ICE and haven’t had any problems with adding new variables. 

When ever I read a variable, I always check to see if the return value is nil. If it is, I set it to whatever the default should be. In the scenario you describe the person going from version 1.0 to 1.1, the value of powerup1 will be nil the first time you try to read it. That because it doesn’t exist in the 1.0 database. You can’t assume it will always be true or false.

-- DELETED --
-- DELETED --

Thanks so much “elbowroomapps” for getting back to me! That makes a lot of sense and I believe that what I do to with “storeIfNew” (currently using ICE) So you are saying that it will not be a problem to add a variable to an ICE box for people who already have a previous version of an app?

For instance here my current ICE  box (one of two)

– PLAYER(S) SETTINGS

 player1 = ice:loadBox ( “player1” )

player1:storeIfNew(“name”, “player1”)

player1:storeIfNew(“score”, 0)

player1:storeIfNew(“hiScore”,0 )

player1:storeIfNew(“promotion”,0)

player1:storeIfNew(“rank”, 1)

player1:storeIfNew(“bonus”,0)

player1:storeIfNew(“bullet”,1000)

player1:storeIfNew(“goldAmount”,0)

player1:storeIfNew(“topGun”,false)

player1:storeIfNew(“topRank”,1)

So for version 1.1 of the app, I could simply add:

player1:storeIfNew("powerups",{"reload", "shield", "nuke"})

In that case, what will happen if in version 1.2 I wanted to add one more item to the powerup table?

like: 

player1:storeIfNew("powerups",{"reload", "shield", "nuke", "XYZ"})

Would the addition of “XYZ” break the app? Should I not use tables but simply do something like:

player1:storeIfNew("powerup1",{"reload") player1:storeIfNew("powerup2",{"shield") player1:storeIfNew("powerup3",{"nuke"}) player1:storeIfNew("powerup4",{"XYZ"})

Thanks again!

Mo

I haven’t use ice so I can’t comment on that part. But with ggdata I use tables, so adding a new element to an existing table and then calling ggdata:save() shouldn’t be a problem. 

@LairdGames, I don’t see any problems with your code, but it’s always good to test. Before submitting to the app store I usually do 2 tests.

Test 1. - Install old version of app and change settings and make sure I have a high score saved. Install new app without removing old app. Run new new app and verify that settings and high score carry over from old app.

Test 2. - Remove old app from device ( this should also remove saved data). Install new app. Run new app and verify all settings are set to default values and high score is 0.

Any ideas? Anybody? I really want to start right and I am trying to avoid issues with updates when I need to add more variables for new features.

Thanks again.

Mo

Hey Mo, I’m not sure what exactly you mean by future proof? I’m using ggdata and I find it relatively easy to easy since you can throw lua tables at it. 

Thanks for getting back to me. Ok, let say I have a box with some variables that save some game data like score and highscore. Then later (a game update) I want to add some new features. Let say those features deals with powerups. So I need to add more variables to the box like powerup1 and powerup2 (Boolean) – Version 1.0 Box.score = 0 Box.hiscore = 0 – version 1.1 (update) Box:set(powerup1,true) Box:set(powerup2,false) Box:set(test,{“one”,“two”}) The question is what happen to people who upgrade to version version 1.1? Is GGData smart enough to read the previous version save data (1.0)? Please note that I did not yet used GGData. I am using ICE at this time so my question above maybe more related to the fact that I do not know how to add variables to ICE boxes without having reading issues on older app version (ie: using boxes with less variables…like above with GGData example) Not really sure I make any sense so please ask away if you need to:) THANKS again! Mo

I use ICE and haven’t had any problems with adding new variables. 

When ever I read a variable, I always check to see if the return value is nil. If it is, I set it to whatever the default should be. In the scenario you describe the person going from version 1.0 to 1.1, the value of powerup1 will be nil the first time you try to read it. That because it doesn’t exist in the 1.0 database. You can’t assume it will always be true or false.

-- DELETED --
-- DELETED --

Thanks so much “elbowroomapps” for getting back to me! That makes a lot of sense and I believe that what I do to with “storeIfNew” (currently using ICE) So you are saying that it will not be a problem to add a variable to an ICE box for people who already have a previous version of an app?

For instance here my current ICE  box (one of two)

– PLAYER(S) SETTINGS

 player1 = ice:loadBox ( “player1” )

player1:storeIfNew(“name”, “player1”)

player1:storeIfNew(“score”, 0)

player1:storeIfNew(“hiScore”,0 )

player1:storeIfNew(“promotion”,0)

player1:storeIfNew(“rank”, 1)

player1:storeIfNew(“bonus”,0)

player1:storeIfNew(“bullet”,1000)

player1:storeIfNew(“goldAmount”,0)

player1:storeIfNew(“topGun”,false)

player1:storeIfNew(“topRank”,1)

So for version 1.1 of the app, I could simply add:

player1:storeIfNew("powerups",{"reload", "shield", "nuke"})

In that case, what will happen if in version 1.2 I wanted to add one more item to the powerup table?

like: 

player1:storeIfNew("powerups",{"reload", "shield", "nuke", "XYZ"})

Would the addition of “XYZ” break the app? Should I not use tables but simply do something like:

player1:storeIfNew("powerup1",{"reload") player1:storeIfNew("powerup2",{"shield") player1:storeIfNew("powerup3",{"nuke"}) player1:storeIfNew("powerup4",{"XYZ"})

Thanks again!

Mo

I haven’t use ice so I can’t comment on that part. But with ggdata I use tables, so adding a new element to an existing table and then calling ggdata:save() shouldn’t be a problem. 

@LairdGames, I don’t see any problems with your code, but it’s always good to test. Before submitting to the app store I usually do 2 tests.

Test 1. - Install old version of app and change settings and make sure I have a high score saved. Install new app without removing old app. Run new new app and verify that settings and high score carry over from old app.

Test 2. - Remove old app from device ( this should also remove saved data). Install new app. Run new app and verify all settings are set to default values and high score is 0.