Saving and Loading Attributes
ADSentertainment
Member Posts: 397
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
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
+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.
@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?
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.
Need Help? Email Me | Templates | Full Game Source Code
To reference a table row, you don´t need the quotes.
Mental Donkey Games
Website - Facebook - Twitter
Struck out that part. Thanks for correcting it!
Need Help? Email Me | Templates | Full Game Source Code
@bjandthekatz Thanks for the reply! I'll give this a try.
you can name rows and columns..cool!