Dynamic save and load system.

Hey everyone.
What I’m searching for is a script to save and load properties from a file (but than in a dynamically way).
The file could look like this:

[TABLE=“class: outer_border, width: 500”]

health = 10
coins = 670
music = True
soundFX = False
pizza = -69

[/TABLE]

What I want the script to do is this:
If I want to get the value ‘pizza’ the script will search in the file until he finds ‘pizza = …’ and then get the value what is behind the ‘=’
So that means it doesn’t matter on which line of the file ‘pizza = -69’ is written.

What I also want the script to do is this:
If I want to save the value ‘soundFX’ to ‘True’ the script will search until he finds ‘soundFX = …’ and then replace the current value to the new value.
So that means I don’t have to save EVERY value again to the file but just replace 1 value.

I know another script that can save and load things but it is not like I would love to have it.
I know this is a pretty dynamic script that I want,
but can you help me with this?
Thanks.

(Sorry for my English)
In my opinion better way is using GlobalDict. Everyone can open txt file and change some information. If you want i can paste my script to save/load GlobalDict.

Why would you want something like that if the globaldict can handle the saving part?
or you want to have a cheat option? so players can adjust the settings by opening the file?

-.- serious… I NEVER heard of globaldict ever before… thank you very much… It is much much much easier than I always did… lol…
Thank you

You could try the saveloader 1.1(or what version?) in game resources which saves every data of object, or… I will post a text versions script later…

No problem, you could also done a search for a save load script, you would have seen that most of them these days use globaldict.
And the best part of it, it’s encrypted too, so they can’t modify the file.

ps: Je kan mijn script ook gebruiken als je geen zin hebt om er zelf 1 te bouwen, staat wel in mijn handtekening.

Grappig om te zien dat ik tegen een Nederlander zat te praten :stuck_out_tongue:

But I understand I can save/load globaldict with the game actuator and I can use logic.globalDict[‘name here’] to set and get the values?
Pretty simple…

Die script van je lijkt me erg handig, maar als globaldict werkt (zoals ik nu begrijp dat het werkt), lijkt me dat handiger in mijn geval.

Yes it’s like that.
or u can use python to save the globaldict.

#die script van mij gebruikt GD, het slaat alle scenes, objects en inactive objects op, inclusief properties, positie, rotatie, snelheden etc :wink:

Thanks

(Ik zal die script van jou zekersteweten tussen me bge bookmarks zetten want hij kan heel er goed van pas gaan komen)

Although the globalDict is probably what you want to use for this, you can also utilize python’s shelve module to save/load data. I wouldn’t recommend it for this specific use, but it can have its uses. Say you want to save/load some data for testing/debugging purposes…

For the record, globaldict isn’t encrypted when it saves, it is just a non human readable format.

Ok, but I don’t care if people are going to abuse the file… I make a game and people can have fun while playing it or they can abuse the globalDict file.