Saving level informations

hey guys

please somebody help me…

I’ve read the blog on how to create level selection menu:

https://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/

and i’ve too read the load save module of coronarob :

https://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/

so i got one doubt:

How can i save this table??? how to unlock next level when i get 3 three stars in level 1?? and how to save all this information using loadsave module ??

Thankss

If you’ve followed the first tutorial, you should have a table named “myData”. That table as a member table called “settings”. All of your apps settings should be in that table including what levels are unlocked, the score and number of stars for that level.

If so, then to save that table after making an update (and assuming you named your loading and saving module “loadsave”, then you would simply do:

loadsave.saveTable( myData.settings, “settings.json” )

Rob

Yes i know that
But suppose i have my first level unlocked… then when i get three stars in that level, i should unlock my second level… how to achoeve this ???

You have to call
loadsave.saveTable( myData.settings, “settings.json” )
To save data after a change is made inside myData.settings table.
Beware reading and writing to files may cause some slow downs so save wisely.

You will off couse need some code once you beat level 1 to modify myData.setting table to unlock level 2.

I can’t advise you on what you should do in your game. You have to make your own rules. Most games will unlock the next level if the player gets one star and they can replay the level to try and score three stars. But your game is your game and you have to decide what works for you.

Rob

If you’ve followed the first tutorial, you should have a table named “myData”. That table as a member table called “settings”. All of your apps settings should be in that table including what levels are unlocked, the score and number of stars for that level.

If so, then to save that table after making an update (and assuming you named your loading and saving module “loadsave”, then you would simply do:

loadsave.saveTable( myData.settings, “settings.json” )

Rob

Yes i know that
But suppose i have my first level unlocked… then when i get three stars in that level, i should unlock my second level… how to achoeve this ???

You have to call
loadsave.saveTable( myData.settings, “settings.json” )
To save data after a change is made inside myData.settings table.
Beware reading and writing to files may cause some slow downs so save wisely.

You will off couse need some code once you beat level 1 to modify myData.setting table to unlock level 2.

I can’t advise you on what you should do in your game. You have to make your own rules. Most games will unlock the next level if the player gets one star and they can replay the level to try and score three stars. But your game is your game and you have to decide what works for you.

Rob