I need a highscore-system for my game (Space Invaders…).
I used the basic idea used in this file: http://www.blendpolis.de/download/file.php?id=58119
(pressing Q and 1 will save the property, pressing W and 2 will load the property [the prop in the game can be changed with spacebar]).
The script creates a .bgeconf textfile [relativ to the .blend] which SHOULD hold the highscore.
It works pretty fine, the problem though is, that the textfile that this script creates actually doesn’t save the property. It always saves “0”.
In conclusion: as long as you don’t quit Blender, the script works just fine (for whatever reason…?).
But as soon as you quit Blender and reopen it the highscore is lost - and THIS shouldnt happen!
I’m not very good in describing problem, it would be nice if you would make yourself a picture of this problem…
Please note: I’ve got no Python knowledge. Therefore I’m already overwhelmed by these very few lines of script.
Not really.
“3” is the default value.
It can be changed with the spacebar.
Then you can save the changed value with Q and 1.
Then you quit and reopen Blender (and the blendfile).
Now press W and 2 and it SHOULD load the modified property value - which it doesnt because the external saved textfile is all messed up.
Strange…
I tested it with multiple builds (and an exported game runtime) - they all failed.
As soon as I stop the bge or restart Blender all the data is lost…
The save-textfile I get is called “Save_Load.bgeconf”, but it always has the follwoing content:
“{0” (without “”)
…mhh…
Is there any alternative to actually permanently save (and later load) a integer-property in an external txt-file?
Yes - when I actually set GlobalDict to something before save (press 1). But when GlobalDict is empty is saves {0 - witch may be binary data that just by chance is printable - but probably meaning ‘empty dict’ just as well
I do not know the binary representation of a dict. I’m pretty sure that I do not need to know that ;).
I think there must be an error in the onsole when trying to read “Cube” from global dict, as it wasn’t loaded from file the must be an KeyError. Finally this means that the property can’t be overwritten.
Ok, I think I must’ve done something in the wrong order - however, it seems to work (at least for my needs) now.
As usual, thanks for the help anyways.