Integers and Index not Loading/Saving, but Booleans do
Hey everyone,
I have already made another forum post regarding this issue, but since then I've been intensively trying to fix the issue by running tests and making new builds with small changes and all sorts of stuff. Basically this post will detail all the tests, the expected outcome (if applicable) and the actual outcome.
Throughout this, I will use my integer (later on index) attribute HighScore as an example.
So basically, initially it looked like my integer attributes that held stats like Deaths, Kills, Coins etc. were not either loading or saving (on starting the game after playing it once, all the stats returned to their initial values of 0). So I decided to look into it and see if they had the right keys and the right attributes etc. Everything matched up, I desk checked three times and there was not a single problem with what I was doing.
After messing around with everything, trying to keys, making new integer attributes to wipe any possible connections with the integers that may be causing the issue, I decided to run a test.
Test #1: Boolean and Integer
Here, I made a new boolean attribute called "testBoolean" (initial value = false) and an integer attribute called "testInteger" (initial value = 0). There are two scenes where the loading and saving occur, being the intro scene with my company logo (where everything loads), and the Post-Game Scene showing coins collected and other game stats (where everything saves). What I did, was in the same actor that ran the save behaviours, I placed two behaviours for "testBoolean" where it changes the value to true, and saves it under the key "booleanKey". Then, in the same actor, I placed another two behaviours, one that increments "testInteger" to +1 and then saves it under the key "integerKey".
I put two loading attribute behaviours in the initial scene to load them before the game starts, along with the other attributes that load into the game.
In the main menu, I have an actor that displays the values of the two attributes, so I know what value they should be.
OUTCOME
I made an iOS build and played through the game. I reached the Post-Game scene, checked the main menu to see the outcome. The displayed text read "boolean = true and integer = 1". So that shows that the attributes have been changed from their initial values. So, I closed the game, and ended the process, and started it up again.
Initial scene starts, menu loads. It reads: "boolean = true and integer = 0"
So, integers don't work for some reason? I sent away a support ticket and didn't get much of a response back (which was my own fault because I didn't have the amount of detail I have in this post).
Conclusion for Test #1
After dealing with my mix of anger and confusion, I figured I should try another numerical attribute type, and seeing as none of my stat attributes never go negative, I think I will try an index attribute.
Test #2: Boolean and Index
I left the testBoolean behaviours and rules as they were, but made a new indexnattribute under the name "testIndex". I gave it the key "indexKey" and gave it the same incremental change in the post-game scene as the integer. I changed the main menu actor that displays the values, and a make another build for the iOS.
OUTCOME
I made an iOS build and played through the game. I saw the main menu, it read "boolean = false and index = 0". As expected (I have another attribute that sets the boolean back to false for testing reasons). I reached the Post-Game scene, checked the main menu to see the outcome. The displayed text read "boolean = true and index = 1". Okay, awesome. Close. End Process. Start again.
Main menu reads: ""boolean = true and index = 1".
Brilliant! Indexes work!
Conclusion for Test #2
From what I can see, the indexes can load, sweet. Time to apply this.
Test #3: Changing the HighScore integer to an Index known as HighScoreNew
Title pretty self explanatory, removed the HighScore integer attribute and made a new index attribute HighScoreNew. All the behaviours are in place, everything is good. Time to test.
OUTCOME
Ran the game, played, got a high score of 5. Checked the stats screen "Highscore = 5". Good.
Quit. End process. Open game.
Goto stats screen.
"Highscore = 0"
0.
0.
I desk checked over and over again, I tried it with my "deathsNew" index attribute.
Died twice, deaths in the stats page reads "deaths = 2"
Quit. End process. Open game.
"deaths = 0"
I have spent hours endlessly desk checking, making new attributes for different starts, keys, everything and nothing is fixing this problem. In fact, the testIndex attribute I last used now returns the value of 0 now.
Can someone please tell me what the hell is going on!?
Developers please answer my cries of pain.
Comments
Can you post your project file (.zip it first)?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I don't feel too comfortable posting my work publicly.
I completely understand. The problem is that small errors can cause the problems you're mentioning. An extra space or incorrect key name could be the issue.
Would you feel comfortable sending me a link via private message to download the file from a media-sharing site? If not, maybe you can post some screenshots of the relevant save/load behaviors.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Saving the HighScoreNew index attribute: http://puu.sh/dLquR.png
Loading the HighScoreNew index attribute: http://puu.sh/dLqyg.png
That looks right. It looks like the Load Attribute behavior is in a rule. Typically, you wouldn't need a rule but would just load the attribute at the top of your actor's rule list as a standalone behavior. What is the condition for that rule? If you add a Log Debugging Statement to that rule and open the Debugger window, does the statement appear?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Oh no it's in a group with the rest of the Load Attribute behaviours.
I've categorised them so if I want to find something it's easier to find.
Oh, okay. Well, I'm stumped.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Don’t use the expression editor when typing in the key to save/load.