Quick Links: Gideros Home | Download Gideros | Developer Guide
Save basic data online
  • Hi all,

    Im finishing my game, and I want to save some basic data (lives,level progress,...) of each user. Im using gamecenter and Google play services for leaderboards... Actually I save this data in a local .txt, but I want to put It online.

    I have been looking for answers, in this fórum...and I have seen some methods REST based like firebase or kinvey, i decide start with firebase and gideros, but the plugin i have found have no authentication function ( was in a 2012 thread).

    Someone of you have used firebase or kinvey. Do you recomend me another method for this basic operation.

    Thanks a lot.
  • SinisterSoftSinisterSoft +1 -1 (+1 / -0 )
    Maintainer
    Do you mean for loading into another device they own - if so you could save it to a google 'slot' and load it back on the other machine.

    Likes: theone10

  • Liking this! And on iOS? :)
    My Gideros games: www.totebo.com
  • pie +1 -1 (+1 / -0 )
    Member
    How do you save to a Google slot? :)

    Likes: theone10

  • @sinistersoft i dont know how to do that. I just thinking in some method 100% gideros friendley. :)
  • hgy29hgy29 +1 -1 (+2 / -0 )
    Maintainer
    You can use Gaming plugin for this (at least with Google Play services):
    • Gaming:loadState(key) --numeric key, raised STATE_LOADED or STATE_ERROR
    • Gaming:updateState(key, data[, immediate]) --update data, numeric key, can raise STATE_CONFLICT or STATE_ERROR
    • Gaming:deleteState(key) --delete data for numeric key, can raise STATE_DELETED or STATE_ERROR
    • Gaming:resolveState(key, version, data) --resolve state conflict for slot key with version and data, should be called if STATE_CONFLICT event was dispatched, may raise STATE_LOADED event for new resolved data
  • Thanks @hgy29 , sounds nice. I have been looking for info about It, and looks its ready for iOS too.

    I have reading saved games info and they have changed the system on July this year. Hope gideros plugin keep working.

    About functionallity, sometimes will be nice some examples... Because what is key argument in the functions. I know data is the info you want to save. But if I want to save the content of two different variables, how I have to do? Save each variable in different key? :-?
  • totebototebo +1 -1 (+1 / -0 )
    Member
    If you guys get it to work on Google Play and iOS, let us know! I want to save progress in the cloud, but my tests all fail with the Gaming plugin.

    Likes: theone10

    My Gideros games: www.totebo.com
  • pie +1 -1 (+1 / -0 )
    Member
    @theone10 a table or a json string?

    Likes: theone10

  • SinisterSoftSinisterSoft +1 -1 (+1 / -0 )
    Maintainer
    I convert my table to a json string then save that. When I load it back as a json string I then convert it back to a table.

    Likes: theone10

  • when i try it, i will post my results. Im gonna try.

    @sinistersoft thanks for the info, very useful. @pie is this what you refer?
  • SinisterSoftSinisterSoft +1 -1 (+1 / -0 )
    Maintainer Accepted Answer
    just before save:
    local saveString=json.encode(savedata)
    if saveString~=lastSavedData then
    gaming:updateState(0,saveString)
    lastSavedData=saveString
    end


    on load:
    local savedata=json.decode(e.data)
    if savedata then
    --here process incoming saveData table

    Likes: theone10

  • pie +1 -1 (+1 / -0 )
    Member
    @theone10 yes that's what I intended, but I never tried to do it :)

    Likes: theone10

  • theone10theone10 +1 -1 (+1 / -0 )
    Member
    just months later... i try it. And on android goes perfect, in some weeks i'll try on ios.

    Thanks again guys :D

    Likes: totebo

  • totebototebo +1 -1
    Member
    Let us know how you get on!
    My Gideros games: www.totebo.com
  • theone10theone10 +1 -1
    Member
    The first i init gaming plugin and add to stage the event listeners for login(complete/error) and of the state(loaded/error) and I do the login.

    When raise login complete i do loadstate(0) and when raise the loaded listener, I do as @sinistersoft wrote Up there.. and when saving i do exactly the same example Code. It fails any of event listener I load a local string.

    Now Im handling some conflicts...
  • totebototebo +1 -1
    Member
    Does this work on iOS or Android only?
    My Gideros games: www.totebo.com
  • theone10theone10 +1 -1 (+1 / -0 )
    Member
    Sorry for my late answer. I just try it at the moment on android... soon ill check on ios

    Likes: totebo

  • One thing to remember, at least if you are doing this manually is handle offline (or server down).

    So, if there is something you want to send to your service, if you are offline then queue it (store local file), then the next time the app loads/resumes (or timer) you re-attempt the POST or send attempt. I used this approach for storing high scores in a cross platform way, although I wrote a custom service and host it in amazon aws.
  • talistalis +1 -1 (+1 / -0 )
    Guru
    I totally agree about handling offline. Just want to point out cheating issues in offline files:
    You can use one of those below methods or even combine all of them to increase security;

    1-Be sure to code your own hash system or use any current one so even the files are altered in offline mode you can be aware of it and act according to it, use the online version, warn the user etc... Try to save information in two or more separate files. And link those files secretly together.
    So much simple example not to be implemented in this way:(Just to give you idea)
    Number of Characters of File A must be the beginning of file b
    Number of characters of file B*Number of Characters of File A*10 must be the beginning of file C
    So in any case whenever your program opens those files for reading let it check for this relation between files. If any alterations occurred take necessary action.

    2-You can encrypt your files always.

    3-Logical tests while reading your file data or inside the program. For example: no one can click to screen more than 10 times a second.

    4-Obfuscate your code to false direct your pray. Name hp variable as mana, or name it directly something not meaningful even:D and try not to use order in your save file.

    5-Encrypt your project.

    Of course those things are all can be discovered and despite of all your efforts your file can be altered. But in any way it is fun to implement those for me at least :D

    Likes: antix

  • Just found it here lies more information about the security:
    http://giderosmobile.com/forum/discussion/comment/52127#Comment_52127

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters