[SOLVED] When saving/loading some data is lost

mikhog

  • Posts: 151
I store a lot of data in game attributes. A lot of it is in lists and are not of types that can be saved/loaded but these are not the issue as they are reset on game start.

The issue is that when reloading the game some attributes are sometimes not loaded properly. My testers are getting impatient when their hard work sometimes is lost after restarting the browser :) Anyone having the same problem?

Is there a limit as to how much data you can store in game attributes when saving? Is it a problem that I store other types in game attributes? Could there be a concurrency problem here somehow due to the large amount of data (maybe about 100 attributes, half of these in lists)? Or am I more likely to have screwed something up somewhere else? (I'm not a beginner programmer though, not that I don't screw thing up now and then, just thought it should be mentioned)

You can test the game here if you want:
stencyl.com/game/play/23286

« Last Edit: March 24, 2014, 08:28:51 am by mikhog »
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

Max Finch

  • *
  • Posts: 2187
Stencyl only saves global attributes not local ones, so if you're trying to save local attributes they wont save. Otherwise if you're using Global attributes and those aren't the ones saving I don't know what's up. I've probably used at most 30~50 game attributes and had no problem saving and loading them.

19maxk21

  • Posts: 16
Stencyl only saves global attributes not local ones, so if you're trying to save local attributes they wont save. Otherwise if you're using Global attributes and those aren't the ones saving I don't know what's up. I've probably used at most 30~50 game attributes and had no problem saving and loading them.
\ (•◡•) /

mikhog

  • Posts: 151
The issue is with global attributes
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

amadeus111

  • Posts: 17
Double check where to put saving and loading blocks
lets say I passed one level which changed some global data. if scene switches the another scene with loading block in it. You will get the not updated global data

mikhog

  • Posts: 151
The issue is not during play but when I come back to play another day. Sometimes all values have been saved, sometimes some of them and sometimes none of them...
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

mikhog

  • Posts: 151
Just realized that in the log I can see a warning that says
WARNING: There was a problem binding to the shared object data from FlxSave
WARNING: You must call FlxSave.bind() before calling FlxSave.write()


The second of the lines is wirtten out about 100 times, I guess it's written once for every game attribute I have.

Any ideas? Anyone seen the same issue?
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

rob1221

  • *
  • Posts: 9472
I've seen that error once in one of my games, and it was caused by storing actors in a game attribute list.  Do you have anything in a game attribute list besides numbers and text?

mikhog

  • Posts: 151
Yes I store actor types. These don't need to be saved though. But I do prefer to have them in my game attributes if possible. I guess I could reset them at every scene.

still that wouldn't explain why the local shared object bind fails does it?
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

rob1221

  • *
  • Posts: 9472
I do believe that is the cause.  Since there is the getActorTypeByName() function, you could replace those actor types with text of the actor type names.

mikhog

  • Posts: 151
Omg if that works then it would be so awesome!! Thanks so much, I'm starting to think that the very best part of stencyl is the community!

I saw a post somewhere about how you could create your own lso and save only the data you want, do you think that would help too?
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

mikhog

  • Posts: 151
I tried emptying the lists with actor types in them before saving and that removed the warnings. It did not fix the saving error however. I guess the next step is to save everything in code instead and see if it helps.
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

mikhog

  • Posts: 151
Tried saving in code as suggested by "camaleonyco" in this thread: http://community.stencyl.com/index.php?topic=7043.0

It actually works! This saves the attributes and loads them correctly too. I guess I have a bunch of coding to do now :)
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D