[workaround found] list curruption when using [load save file and then] blocks

Future Freak

  • Posts: 413
I use global attributes lists to store information about my levels, such as best time, number of moves per level etc.  The times list are all set to 0.0 by default, and are set when playing the game.

On starting my game I use a [load save file and then] block to load in the saved settings.

However, this has become more obvious in the fact that list use for number of moves per level is NEVER updated in game by me. It worked fine on first running, run it again and it loads in the save file and the values being pulled out of the list are all NaN.  If I remove the [load save file and then] it then works fine, which points to this being the problem.  Anyone else experienced this?

I've made a simple test. I have a global list, called ListTest pre-filled with 0.0
Scene behaviour as per attached.

Results printed when run for the first time are:
ListTest = 0.0
ListTest = 0.0
ListTest = 0.0
ListTest = 0.0 etc. for all 24 items in list.

When running again and it's loading in the save file, the printed results are:

ListTest = [object Object]
ListTest = [object Object]
ListTest = [object Object]
ListTest = [object Object] etc.

If I wrap the Item in [anything as number] I get: 

ListTest = NaN
ListTest = NaN
ListTest = NaN etc.

Can someone please explain why this is happening?

« Last Edit: May 28, 2012, 12:04:15 pm by Future Freak »

captaincomic

  • *
  • Posts: 6108
Do you do anything else than what you show in the screenshot?
I'm wondering what kind of objects are stored in the ListTest after saving. (Apperently it's not numbers).

Future Freak

  • Posts: 413
Captain,

I don't do anything else, that behaviour is the only thing attached to the scene and is the only thing that runs.

Is there any where that I can see the actual save file to see what's in it?  This is in flash, I'll test later today on my work machine for iOS.

Future Freak

  • Posts: 413
Anyone from Stencyl interested in confirming this as a bug?

rob1221

  • *
  • Posts: 9461
As a workaround, set the default values in a behavior before loading the game.

Future Freak

  • Posts: 413
As a workaround, set the default values in a behavior before loading the game.

This is the issue - I already DO set them all to 0.0 (or some other random values for testing) as a default. It all works fine, until I use the load block, which then messes them up.

Future Freak

  • Posts: 413
I have uploaded a test to StencylForge to demonstrate the problem called:  ListTest (by paullawton)

dugald

  • Posts: 3
I'm running into this too.  I'm working on an action RPG where each character's stats and stuff are stored in a list game attribute for each character.  Upon loading, when the character is placed back into the loaded scene, the behavior they have that grabs their stats out of their corresponding game attribute and loads them in as their actual stats for their actor only manages to grab NaN's out of the list, which I've verified by having the character display the numeric values of their stats alongside their sprite.

rob1221

  • *
  • Posts: 9461
As a workaround, set the default values in a behavior before loading the game.

This is the issue - I already DO set them all to 0.0 (or some other random values for testing) as a default. It all works fine, until I use the load block, which then messes them up.

You may have to clear your existing save first.  Try disabling the loading block (while keeping the setters in there), play until the game saves, and then enable the loading block again.

Future Freak

  • Posts: 413
As a workaround, set the default values in a behavior before loading the game.

This is the issue - I already DO set them all to 0.0 (or some other random values for testing) as a default. It all works fine, until I use the load block, which then messes them up.

You may have to clear your existing save first.  Try disabling the loading block (while keeping the setters in there), play until the game saves, and then enable the loading block again.

Loading block disabled, iterating shows all the default values of 0, save file is called.
Restarted the game with the loading block back in place, all values set to NaN.

Where is the save file actually stored, when testing with flash? Is there any way I can look at the raw save file to see what's happening?

rob1221

  • *
  • Posts: 9461
I'm not sure where the save file is stored.  Try deleting all of the default values in the game attribute configuration and use the "add ___ to (list)" block instead.

Future Freak

  • Posts: 413
I'm not sure where the save file is stored.  Try deleting all of the default values in the game attribute configuration and use the "add ___ to (list)" block instead.

This works! Thanks Rob.

I removed all the default values from my game attribute list and used a repeat loop to populate them with values.  I then saved the game file.   I removed the repeat loop and re-run the game and it loaded in all the values perfectly. 

So it appears that adding in values via the Stencyl interface are somehow not being saved when using save game correctly, so this is a bug, but at least we have a workaround for the time being.