Saving and Loading Attributes

So I'm adding a save function to my game, and while I KINDA know how saving and loading attributes work, there are a few things I don't know. Like what exactly are the keys for? Am I able to save multiple attributes to a single key? Can I test saving and loading in the actual creator or does it have to be transferred to my device, first? Thanks in advance.

Having trouble with your game? Sounds like a personal problem.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Each key stores a single attribute value and must therefore be a unique name. If you're planning to save and load more than a couple attributes it pays to use a table instead.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited May 2015

    +1 for the table way its a lot cleaner and you can save all the attributes in that table with one simple save table.

    Yes you can test in the creator pressing reset will work but if you press back to edit anything you will start from default.

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @DeepBlueApps or @tatiang Do either of you have a tutorial or link to point me in the direction of saving/loading attributes using a table?

    I'm trying to save high scores, virtual currency, missions completed, characters collected...etc. So, I believe the table is the route I should go for saving tons of attributes?

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    edited July 2015

    @As Of Latte said:
    Do either of you have a tutorial or link to point me in the direction of saving/loading attributes using a table?

    Create a table with 1 column and as many rows as you need.
    Name all of the rows what you want to save them as (ex. highScore)

    change attribute tableCellValue(yourTableHere, What you called the row here, 1)
    example: change attribute tableCellValue(TB-scores, missionsCompleted, 1)
    save table.

    To determine the new high score you would use
    if game.score > tableCellValue(TB-scores, highScore, 1)
    change attribute tableCellValue(TB-scores, highScore, 1) to game.score
    save table.

    The reason for using the quotation marks is so that you can reference the row using the title instead of having to know the row number.

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    @bjandthekatz said:
    The reason for using the quotation marks is so that you can reference the row using the title instead of having to know the row number.

    To reference a table row, you don´t need the quotes.

    Mental Donkey Games
    Website - Facebook - Twitter

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375

    @NipaDidIt said:
    To reference a table row, you don´t need the quotes.

    Struck out that part. Thanks for correcting it!

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @bjandthekatz Thanks for the reply! I'll give this a try.

  • tintrantintran Member Posts: 453

    you can name rows and columns..cool!

Sign In or Register to comment.