Save Game on a Server

I want to save the player’s savegame files on a server so they can be restored if the player reinstalls the game. 

Can anyone outline how I should go about doing this?

Thanks!

Gullie 

Yes, absolutely. But it’s complicated. I am interested in any other way someone has that might be more elegant than this, but this is what I have done - and it works great - the full code at the bottom hasn’t been fully tested for the ‘loaded’ event.type, but other that that, all code here works 100%.

Step 1) Make certain to have a unique deviceID on your platform of choice or get a unique name or ID from the gamer.

Step 2) Create a MySQL database with two columns - column 1=unique deviceID or name from gamer, column 2=your large text file that you want to save

Step 3) Get an SSL cert for your server to keep the data safe

Step 4) Create a PHP script on your server that will receive data like this: (i.e. https://www.yourserver/savegame.php?data=yourURLencodedText?checksum=?). Have the script return a value so that your webListener (#7 below) can check to know with certainty if the data was actually received

Step 5) Make sure to create an algorithm for your encodedText which can encode and decode the checksum value properly, to insure that no one can enter info into your database without knowing the algorithm - this needs to be created in Lua and in PHP

Step 6) Use network.request (textToSend,“GET”, webListener)  --textToSend is your send string

Step 7) Setup the webListener to check the VALID value and verify that the server received and stored the data properly.

function webListener( event )
    if ( event.url ) then

    – you can confirm your URL here
    end
    if ( event.isError ) then
    – code here if network error

    end

    if ( event.type ) == “loaded” then
      e=event.response

      – check if response VALID to know if it saved properly
    end

end

Hope this helps.

The most common way is to either use the Game Center/Play Store APIs to store user’s details or you can use something like Coronium.IO (http://coronium.io) which provides a module to handle all the network uploading / downloading and lets you write your own server software. They even have a game module to handle things like player state etc

The upside to using Coronium.IO or the Game Center/PlayStore APIs is that it might be easier for you to implement. The downside is that your load game and save game feature will add new external dependencies which you have no control over.

If you don’t want to use Coronium GS you can just implement your own Coronium.IO game server, like I did. There is no external dependency with that because it is *your* AWS instance and *your* Lua code executing on the server - Coronium do not have control of it - *you* do. Even if they were to shut down operations, *your* code would continue to execute and continue to be maintainable.

http://www.cloudant.com scalable DBaaS would be my choice. They give away heaps of reads/writes and GB a month for free.

Check out my Cloudant code for Corona here.

http://simon.fearby.com/blog/?s=Cloudant

http://code.coronalabs.com/code/saving-cloudant-dbaas-corona-sdk

https://github.com/SimonFearby/Lua-Corona/blob/master/SavingToCloudantDBaaSFromCoronaSDK.lua

I’ve also worked with Cloudant (and Apigee and Kinvey) … there are a variety of MBaaS (Mobile Backend as a Service) vendors out there today.  All of them could be good choices; as @FearTec notes, they all generally come with some level of free service, then pay-as-you-need beyond that.

Some of my code that you’re welcome to play around with:

Thank you all bunches!

Yes, absolutely. But it’s complicated. I am interested in any other way someone has that might be more elegant than this, but this is what I have done - and it works great - the full code at the bottom hasn’t been fully tested for the ‘loaded’ event.type, but other that that, all code here works 100%.

Step 1) Make certain to have a unique deviceID on your platform of choice or get a unique name or ID from the gamer.

Step 2) Create a MySQL database with two columns - column 1=unique deviceID or name from gamer, column 2=your large text file that you want to save

Step 3) Get an SSL cert for your server to keep the data safe

Step 4) Create a PHP script on your server that will receive data like this: (i.e. https://www.yourserver/savegame.php?data=yourURLencodedText?checksum=?). Have the script return a value so that your webListener (#7 below) can check to know with certainty if the data was actually received

Step 5) Make sure to create an algorithm for your encodedText which can encode and decode the checksum value properly, to insure that no one can enter info into your database without knowing the algorithm - this needs to be created in Lua and in PHP

Step 6) Use network.request (textToSend,“GET”, webListener)  --textToSend is your send string

Step 7) Setup the webListener to check the VALID value and verify that the server received and stored the data properly.

function webListener( event )
    if ( event.url ) then

    – you can confirm your URL here
    end
    if ( event.isError ) then
    – code here if network error

    end

    if ( event.type ) == “loaded” then
      e=event.response

      – check if response VALID to know if it saved properly
    end

end

Hope this helps.

The most common way is to either use the Game Center/Play Store APIs to store user’s details or you can use something like Coronium.IO (http://coronium.io) which provides a module to handle all the network uploading / downloading and lets you write your own server software. They even have a game module to handle things like player state etc

The upside to using Coronium.IO or the Game Center/PlayStore APIs is that it might be easier for you to implement. The downside is that your load game and save game feature will add new external dependencies which you have no control over.

If you don’t want to use Coronium GS you can just implement your own Coronium.IO game server, like I did. There is no external dependency with that because it is *your* AWS instance and *your* Lua code executing on the server - Coronium do not have control of it - *you* do. Even if they were to shut down operations, *your* code would continue to execute and continue to be maintainable.

http://www.cloudant.com scalable DBaaS would be my choice. They give away heaps of reads/writes and GB a month for free.

Check out my Cloudant code for Corona here.

http://simon.fearby.com/blog/?s=Cloudant

http://code.coronalabs.com/code/saving-cloudant-dbaas-corona-sdk

https://github.com/SimonFearby/Lua-Corona/blob/master/SavingToCloudantDBaaSFromCoronaSDK.lua

I’ve also worked with Cloudant (and Apigee and Kinvey) … there are a variety of MBaaS (Mobile Backend as a Service) vendors out there today.  All of them could be good choices; as @FearTec notes, they all generally come with some level of free service, then pay-as-you-need beyond that.

Some of my code that you’re welcome to play around with:

Easiest way USE parse with an array as an object per unique user, when logged in have parse populate all things saved, very easy especially with graphics how you can have it in a table forum

Thank you all bunches!

Keep in mind that if you use a 3rd party service, if they have trouble (i.e. IGN - GameSpy), your game will no longer load or save properly.

Easiest way USE parse with an array as an object per unique user, when logged in have parse populate all things saved, very easy especially with graphics how you can have it in a table forum

Keep in mind that if you use a 3rd party service, if they have trouble (i.e. IGN - GameSpy), your game will no longer load or save properly.

Hi,

As @troylyndon mentioned, the one thing to consider is that if a 3rd party service goes out of business (and it happens more than you think, and quickly) you are basically screwed in not only the lapse of data, but also rewriting your code base for whatever other tools you have to transfer to.

This is a major issue in my opinion, a shiny site does not mean it’s your bedrock.

Full disclosure; I created Coronium Cloud exactly for this reason. It may not be pretty, but its been on the dancefloor for a couple years now. It has proven its abilities.

To clear up a common misconception, Coronium is free, 100% free. You host it, you expand on it using Lua, you basically “own” it. You are the service provider. If gravity decided it no longer wanted to be my friend, and I floated off the face of the Earth, it’s still yours. Coronium is very similar in nature to a regular server stack like LAMP. It is not a service, paid or otherwise.

But, that being said, Coronium would be more than you need unless you planned on using it for other things.

My alternate suggestions would be Coronium ACE, which is a smaller, simpler, and newer version of some Coronium innards. Most specifically an API and Data storage that can also be expanded with Lua.  The other is Parse.com + the new Parse plugin. Now, of course I’ve just said don’t use 3rd party, but Parse is owned by Facebook, so they probably are not going anywhere, anytime soon. The main issue I find with Parse is speed. It has slowed quite a bit since the FB acquisition.

Hope some of that helps for future viewers.

Cheers